Ruby on rails 4 Getting error in rails after installing devise

I am getting this error after installing devise for users C:3:in `rescue in execute_if_updated': Rails::Application::RoutesReloader#execut e_if_updated delegated to updater.execute_if_updated, but updater is nil: #<Rail s::Application::RoutesReloader:0x3900780 @paths=["C:/ror/wishlistize/config/rout es.rb"], @route_sets=[#<ActionDispatch::Routing::RouteSet:0x393a140>]> (RuntimeE rror) from C:131071:in `execute_if_updated' from C:/Ruby200/lib/ruby/gems/2.0.0/gems/rail

Ruby on rails 4 Gumby 2 with rails

I am trying to integrate the Gumby frame work with rails. I have managed to get the CSS working by including the CSS files however I am finding it difficult. Implementing their javascript. Anyone used Gumby with rails successfully ?

Ruby on rails 4 Unable to replace spree default logo in spree 2.1.3

Used firebug and inspected Spree default logo is coming from /assets/store/logo.png Checked in spree 2.1.3 Version Source code and found default logo is coming from /logo section. path : core/app/models/spree/app_configuration.rb preference :logo, :string, default: 'logo/spree_50.png' Trying to Override, the default logo using Spree:Config option. Spree::Config.set(logo: "store/logo.png") But it's still redirecting to the old image(spree_50.png) and I am unable to replace the default

Ruby on rails 4 Rails - use custom routes, instead of passing url params

A User has_many accounts, and an Account belongs_to a Role. A Role can be 'student', 'admin', 'instructor'. To view instructors, I could do this: /accounts?filter_by=instructors # controller role = params[:role] @accounts = Account.joins{role}.where{ } What I would like do is this: /instructors And, create a route for each type of account. Im struggling a bit figuring out the best way to create these routes. resources :accounts do collection do

Ruby on rails 4 Rails TypeError when trying to display an array

I try to create and Display errors in Rails, I have a problem for that. Here my code: controller: flash[:errors] = [] flash[:errors] << [:message => t('clubs.errors.no_contact'), :strong => new_member_params[:email] + ': '] view: <% if flash[:errors].present? %> <% flash[:errors].each do |error| %> <div class="alert alert-danger"> <a class="close" aria-hidden="true" href="#" data-dismiss="alert">×</a> <str

Ruby on rails 4 use devise sign_in view in layout

I have 2 layout applicattion.html.erb login.html.erb I use devise. in application_controller.rb I write this code: protect_from_forgery with: :exception layout :another_by_method private def another_by_method if user_signed_in? "application" else "login" end end by this code, if user don't login_in, login.html.erb show. I want use devise sign_in form in login.html.erb, but because of this code all of the page are redirect_to login.html. I use below code

Ruby on rails 4 Undefined method [model]_url for nested resource

I am working on a nested resources project, and am getting an error in my steps controller: def create @step = respond_to do |f| if f.html { redirect_to @step, notice: 'Step was successfully created.' } f.json { render action: 'show', status: :created, location: @step } else f.html { render action: 'new' } f.json { render json: @step.errors, status: :unprocessable_entity } end end end The error

Ruby on rails 4 Rails 4: Remove not null constraint from table column with migration?

Given the following schema.rb: create_table "people", force: true do |t| t.string "name", null: false t.integer "age" t.integer "height" t.string "email" t.boolean "married", default: false t.text "bio" t.integer "fav_number" t.decimal "lucky_num", precision: 2, scale: 2 t.datetime "birthday" t.datetime "created_at" t.datetime "updated_at" end I'd like to remove the name default value of null: false. I've tried running a separate

Ruby on rails 4 Execute system command with Rake outside Bundle scope

Let say I have this Rake task: namespace :db do namespace :dump do. desc 'Backup database dump to s3' task :backup => :environment do cmd = ['backup', 'perform', '-t project_backup', "-c #{Rails.root.join 'lib', 'backup', 'config.rb'}"] system(*cmd) # ...I've tried `` & exec() sa well, same thing end end end Backup gem is stand alone ruby gem application which dependencies needs to be isolated from application bundler. In other word

Ruby on rails 4 Ruby on Rails + Amoeba Gem: undefined method 'macro'

I tried amoeba version 2.0.0 in the Rails console (with Ruby 2.1). This is my model: class Dict < ActiveRecord::Base belongs_to :user has_many :cards, dependent: :destroy has_many :idioms, through: :cards end class Card < ActiveRecord::Base belongs_to :dict has_many :idioms, dependent: :destroy amoeba do exclude_field :dict_id end end class Idiom < ActiveRecord::Base belongs_to :card amoeba do include_field :repres include_field :card_id include_field

Ruby on rails 4 Is accessing a value from params hash directly via a key insecure?

I just had a debate with a coworker, we have a nested route: /foo/:foo_id/bar/:id(.:format) In the controller, I was doing this: Foo.find(params[:foo_id]) He said I should be getting foo_id via strong params, which I disagreed with. I thought strong params is to ensure an array within params does not contain keys you don't specify, and does nothing to the values themselves. Who is right? Edit, and in the case of updating a record, is the below right or wrong? So, getting the id itself v

Ruby on rails 4 Travis-CI "The command "bundle exec rake" exited with 1." + mystery 404 error

bundle exec rake runs all tests perfectly fine locally. However, Travis CI keeps blowing up with Problem accessing /authentication without giving much more info to go on. Here's one of the failed builds: For the life of me, I cannot figure out what is causing an authentication error when Travis tries to run bundle exec rake. Here's the project repo:

Ruby on rails 4 Converting local numbers into international format (for use with Rails and services such as Nexmo/Twilo)

I want to verify my users phone numbers using a service such as Nexmo or Twilo. To send a message via these services I need to supply the international number, however, I do not want to have to ask my users to provide the full international number - just their normal number that they would give to anyone in their own country (I don't expect them to know their international dialling codes, etc). So what is the best way to convert a local national number into an international one? As well as the

Ruby on rails 4 How can i upload multiple files for my existing project using carrierwave

here is the attachment code in my _form.html.erb <div class="control-group"> <%= f.label :attachment , :class => 'control-label' %> <div class="controls"> <%= f.file_field :attachment, :class => 'file_field', multiple: 'true' %> </div> </div> here is my model invoice_details.rb class InvoiceDetail < ActiveRecord::Base mount_uploader :attachment, AttachmentUploader #validates :invoice_number, :supplier_name, :att

Ruby on rails 4 Activeadmin Rails register model multiple times - confuses routes

I'm trying to setup the same model in multiple menus, one as a sortable tree and the other as a regular crud. This instance registered as a crud is nested within another model so.. I have ActiveAdmin.register Parent do end ActiveAdmin.register Child do belongs to :parent end ActiveAdmin.register Child, as: 'Child1' do menu :parent => "Parent1" end ActiveAdmin.register Child, as: 'Child2' do menu :parent => "Parent1" end This works on my local machine but goes crazy when deploye

Ruby on rails 4 Rails Active Record Displaying Model Row in View Unbidden

Issue: I am relatively new to rails. I figured out how to display data from associated models however the whole table row is being rendered in what looks like an array in the bottom of the div. Any suggestions would be welcome. [#<ShortTermGoal id: 1, user_id: nil, contact_id: 4, title: "small blah", description: "blah blah blah ", created_at: "2015-05-31 13:58:31", updated_at: "2015-05-31 13:58:31">] View Code: <div class="group"> <h3>Personal Goals</h3>

Ruby on rails 4 link to update model parameter yields missing or empty value error

I'm trying to give provide a series of links that when selected will update a corresponding user's parameter to that which is supplied by the link without rendering a form. The only problem I'm running into is that when it calls the update method I get: param is missing or the value is empty: user. update method def update @user = User.find(params[:id]) if @user.update(user_params) redirect_to list_path flash[:success] = "User updated" else redirect_to list_path flash[:alert] = "User

Ruby on rails 4 Rails form_tag does not send params if disabled: true

I have a form_tag in my view and a few text_field_tag nested in it. I do not want the user to edit the text fields so I did :disabled => true. The problem: If I do :disabled => true the text field value is not passed in params hash, while if I do :readonly => true it does send the values in params hash Is this expected? If yes then there is no mention of this in the documentation. If not, then should I file a issue in GitHub?

Ruby on rails 4 One user has multiple uids with omniauth facebook login

I implement omniauth and facebook plugin with devise for login system. However, it seems the same facebook account will return different token uid, How could I handle the kinds of situation in Rails. Does my new designed method has bad side effect ? I'm planing to use only facebook omniauth as the only way to login my system. Original create user method def self.from_omniauth(auth) where(provider: auth.provider, uid: auth.uid).first_or_create do |user| user.provider = auth.provider

Ruby on rails 4 Chartkick Timeline undefined method `each_pair' for#< Array:... > in Rails 4

I'm having an issue with a Chartkick Timeline chart in Rails 4. When the page loads this error is thrown: "undefined method `each_pair' for#< Array:... >" in the Chartkick code as shown below; def chartkick_deep_merge(hash_a, hash_b) hash_a = hash_a.dup hash_b.each_pair do |k, v| tv = hash_a[k] hash_a[k] = tv.is_a?(Hash) && v.is_a?(Hash) ? tv.deep_merge(v) : v end hash_a end I have attempted various iterations of the code using to_json, as_json, @events.each do

Ruby on rails 4 rails 4 spree app doesn't show fontawesome icons

I have a Spree Onlineshop based on Rails 4 with the bootstrap and fontawesome gems. Here an excerpt of the relevant codesnippets. Gemfile: # Twitter's Bootstrap 4 gem 'bootstrap', '~> 4.0.0.alpha1' # FontAwesome gem 'font-awesome-sass', '~> 4.4.0' # Enables Haml as the templating engine gem 'haml-rails', '~> 0.9' application.scss: @import "bootstrap"; @import "font-awesome-sprockets"; @import "font-awesome"; and in my spree_application.html.haml: .row .col-sm-2 %p lorem

Ruby on rails 4 Scope in Rolify to filter out Users with specific roles (Rails 4)

I am far too new to scopes to figure this out. I have a list of all users on a page, and I'd like to be able to filter out the list based on role (using a checkbox or link at the top). I can get this to work with another column in the table (such as location), but I cannot figure out how to do so with roles. In my model, I have this to make it work for location: scope :location, -> (location) { where("location LIKE ?", "#{location}%") } And then in my controller I have @users = User.lo

Ruby on rails 4 ROR + Run Rake Job automatically after deployment

In Rails deployment, some times we missed to execute rake db:migrate, rake db:seed or any rake job after deploying the project at regular interval. I am trying to add such script with Rails structure, which will call RakeJob and all such type of script automatically after deployment. Just like in this sequential way :- rake db:migrate rake db:seed rake ( Here Rake is the combination of all rake jobs )

Ruby on rails 4 error : gem install sqlite3 -v '1.3.11'` succeeds before bundling

When I tryed deploying my rails application, the log said error below. EBUG [4b7b573d] An error occurred while installing sqlite3 (1.3.11), and Bundler cannot continue. Make sure that `gem install sqlite3 -v '1.3.11'` succeeds before bundling. cap aborted! SSHKit::Runner::ExecuteError: Exception while executing as [----]: bundle exit status: 5 bundle stdout: An error occurred while installing sqlite3 (1.3.11), and Bundler cannot continue. Make sure that `gem install sqlite3 -v '1.3.11'` suc

Ruby on rails 4 Forwarding an incoming call Twilio to multiple numbers

I have a application where I forward a call to a number using Twilio number as below, @client = twilio_sid, twilio_token @call = @client.account.calls.create( from: twilio_number, to: to_number, method: 'GET', url: "http://some_url", :status_callback => "http://some_url/webhook-callback", :status_callback_method => 'POST', :status_callback_event => ['initiated', 'ringing', 'answered', 'completed'] ) The "url:http://some_url" generates TwiML fo

Ruby on rails 4 Hit / Stat counter in a rails app

I thought a hit counter would be simple enough as it's a pretty basic piece of code to insert to a html page, however when I add statcounter to my rails app, all the navigation links break. Can anyone advise me as to the best way to insert something like this to my app? It works but when I click on a nav link, it just displays the hit counter on a blank page unless I reload the page or , if I use the invisible hit counter, it displays an empty page for whatever nav link I click.

Ruby on rails 4 Uncaught Error: Cannot find module "react"

starting with, i am a beginner in React with Rails and trying things out. I am currently working with routing and i'm not sure where i'm going wrong. Please guide me. I have a container folder with UserWorld.jsx file. Its content are as follows: import React, { PropTypes } from 'react'; import User from '../containers/User'; // Simple example of a React "smart" component export default class UserWorld extends React.Component { constructor(props, context) { super(props, context); //

Ruby on rails 4 Extending the shopify_api gem in rails to retrieve resources only available for Shopify Plus users

In the Shopify API documentation, the resource "User" is offered for those who pay for the Shopify Plus account. See below: Speaking to Shopify's support, because Shopify Plus user's are a minority, the shopify_api gem does not support these calls, so I have to build them myself. I've tried doing this by extending the current ShopifyAPI module and classes like so: module ShopifyAPI class User < Base def self.current(options={})

Ruby on rails 4 Trix and Summer Note issues while content saving in database

I am building a rails blog and I needed to integrate a WYSIWYG editor so I tried with Summernote (v, everything is fine except when I create a new post , content is being saved into the database along with html tags instead of only the formatted text content. Latter I tried with Trix (v 0.10.1) and the same thing is happening.I followed everything correctly from the github docs but this only one issue persists. Thank you in advance. This is the screen shot of the issue:screenshot

Ruby on rails 4 Rails Custom Error Page Working and Not Working

ruby-2.3.7 Rails 5.1.4 I'm trying to learn about error pages in Rails apps: how to create them and how they get called/triggered. I've read quite a few posts and blogs about this. I've found several that use the same approach. It seems simple enough, so I tried to implement it. When I go directly to my new 404 or 500 page: ...myapp/404 or ...myapp/500 I get the correct custom 404/500 page. But when I trigger a different 500 error, I do not. I.e: ...myapp.employee/99999 throws an error b

Ruby on rails 4 Rails remove table

Using rails 4 and generated a table and then did a rake db:migrate to add the table to my schema.rb. However, I have destroyed the table, which removed its model and views but it still seems to appear in my schema.rb file, which is due to the migration. Is it safe to simply remove the lines from my codebase in sublime or is there a particular method for handling this in terminal.

Ruby on rails 4 Do I need a "Users" controller when using Devise in Rails

I am a Rails newbie. I am working on a small Rails4 project trying to improve my skills. I am loosely following M.Hartl's tutorial. As per the tutorial a custom user authentication is built. However I would like to use Devise for User authentication. Do I still need to have a Users controller as in the tutorial? In which cases should I use/not use a Users controller when already using Devise? Concerning the tutorial, do I just skip the controller generating part or do I have to map the actions

Ruby on rails 4 how to specify asset_host in rails 4?

I am using Amazon S3 for file uploads and Cloudfront for serving static assets, and in my config/environments/staging.rb, i wrote ActionController::Base.asset_host = { |source| if source.include?('/assets') "" else "#{ENV['FOG_DIRECTORY']}" end } ActionMailer::Base.asset_host = { |source| if source.include?('/assets') "" else "#{ENV['FOG_DIRECTORY']}" end }

Ruby on rails 4 How do I get SQL logging in Rails 4 WEBrick for a non-development environment?

I'm using Rails 4.1.2. I have some environments which are exact copies of my development environment. In other words, I created them by simply copying config/environments/development.rb to a file with a different name (e.g., destaging.rb). They differ only in the connection information in database.yml. If I issue RAILS_ENV=destaging rails s or rails s -e destaging at the command line, everything works just as I desire, except that I get no SQL logging to STDOUT, which is a bummer. Since my des

Ruby on rails 4 Rails query works then creates an error

I have a query to retrieve all the spots (times) available on a given date. @takenspots = Spot.joins(:reservations).where(' = ?', params[:date]) if @takenspots.any? @availablespots = Spot.where('id != ?', I use @availablespots to populate a select_list. I have 4 different spots per day and the query works only 2 times. (2/4 spots) If a try to book a day where i have 2 spots taken out of 4, it says: SQLite3::SQLException: near ",": syn

Ruby on rails 4 Capybara::NotSupportedByDriverError on integration test with capybara-webkit

I am trying to write an integration test using Capybara and capybara-webkit. I am stuck on trying to confirm an alert dialog. The documentation for capybara-webkit says to set Capybara.javascript_driver = :webkit which I have done, but I don't see how this would affect Capybara::page.driver, which I think is supposed to respond to accept_alert: def test_update_key Capybara.javascript_driver = :webkit visit account_path accounts(:pending_account) click_link "edit_account_key" page.accep

Ruby on rails 4 Assets only compiled after old releases purged when deploying with Capistrano

...I think that's what's happening anyway. I'm deploying a Rails app to EC2 with Capistrano. The deployment always succeeds, but even if I've just pushed JS/CSS changes to Git, the assets won't compile the first time. When I kept 5 releases, I had to repeat the deployment until all of the old releases were eventually removed. I reduced it to 3, and then to 1. Now, I see a new version of the JS and CSS after 2 consecutive deployments. In production there are also multiple application.js and app

Ruby on rails 4 belongs_to not working in rails 4.0

I'm building a small example with rails 4.0. There are something strange when I create a one-many relation between 2 models. A Cluster has_many :request and A request belongs_to :cluster. class Cluster < ActiveRecord::Base has_many :requests paginates_per 10 end class Request < ActiveRecord::Base paginates_per 10 belongs_to :cluster, :class_name => "Cluster" end Then when I create a cluster and insert with some request I get an error def do_cluster requests = Re

Ruby on rails 4 I18n Syntax Ruby on Rail error f.input_field

I am trying to add I18n translations to replace HelloWorld with some translations in my RoR application: <%= f.input_field :misc_details, as: :text, rows: 2, placeholder: HelloWorld %> I added the below key to current en.yml file: en: onboarding: q22: HelloWorld and modified my .html.erb file as follows: <%= f.input_field :misc_details, as: :text, rows: 2, placeholder: t('onboarding.q22') %> but it doesn't work. What am I doing wrong?

Ruby on rails 4 I18n.t does not always load in Rails development

There has been odd behavior of I18n.t with our Rails 4.2 app in development. There was no problem with I18n.t until recently. Without changes in app's configuration, the I18n.t does not load in development. Occasionally the page refresh itself and load with translation. However most of time, there is translation missing error with every I18n.t. Here is the local.rb under initializers: I18n.enforce_available_locales = false I18n.default_locale = 'zh-CN' if Rails.env.production? ||

Ruby on rails 4 Localize / Translate different values for one model field

I use to have roles as an Enum and translate them was easy... I've adopted rolify and now things got more complicated... Rolify adds a table "Roles" to the RoR app, where you have, for example, the field "name" of the role. So I have 4 roles: SuperAdmin Admin Teacher Parent What I would like to do is to translate these four roles into different languages. I've looked at solutions like the gem "globalize" but it only seems to allow to translate one field value, so for example I could say t

Ruby on rails 4 Assets Precompile Capistrano 3.4

I am a newbie in deploying, Using capistrano 3.4 for deploying I am trying to deploy for staging environment, using this task for precompile desc "assets precompile" task :precompile do on roles(:rails) do execute "cd #{release_path} && bundle exec rake assets:precompile RAILS_ENV=#{fetch(:stage)} " end end after :publishing, :precompile But precompile is getting freeze not moving, if i uncomment these above task and deploy then it gets deployed but assets are no

Ruby on rails 4 unable to update habtm table on create method

I have a sessions model and users model, where they have habtm relationship. I have a scenario where all users can be a part of session or only particular users can be part of that session. def attendees=(emails) #ToDo Refactor this piece of code if emails == 'All' emails = User.all.collect(&:email) end raise ArgumentError, 'Input should be an array of emails' unless emails.is_a?(Array) raise ArgumentError, 'Input Array of emails is empty' if emails.empty? self.users = [] emails

Ruby on rails 4 Issue with param not pushing data to database in Rails

Quick one. I'm trying to push a parameter into the database when i'm creating an object. I have it working if I force the integer as with the commented code below however for whatever reason I cannot get it to be added to the database is I use the params[:subscription_id] method. I can see the parameters in my server but cannot see it getting inserted into the certificates table. If i force the integer in my controller it will go through and I can see the subscriptions_id getting passed in. Do

Ruby on rails 4 Getting Error - #<Google::Apis::ServerError: unsupported proxy> while configuring proxy for google-api-ruby-client-0.10.0 gem

I am using google-drive-ruby gem for integrating Google-Drive in my rails project. google-drive-ruby gem has run time dependency on google-api-ruby-client gem. I am trying to configure proxy in configure_client method of http_client_adapter.rb def configure_client(client, request) client.transparent_gzip_decompression = true if true #request.options.proxy #proxy = request.options.proxy proxy = URI('') proxy_user = '*******' pro

  1    2   3   4   5   6  ... 下一页 最后一页 共 18 页