ruby-on-rails-4.1

undefined local variable or method `resource_class' in devise

倾然丶 夕夏残阳落幕 提交于 2019-12-11 02:38:34
问题 I am trying add a attribute called username to devise but rails shows me an error in the following line of code I am using rails 4.0.0 and devise 3 def configure_permitted_parameters devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:username, :email, :password, :password_confirmation) } end Controller application class ApplicationController < ActionController::Base # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. protect_from

Issues using config/secrets.yml variable set from ENV variable on Rails 4.1.0

时光怂恿深爱的人放手 提交于 2019-12-11 01:27:03
问题 Have not played with Rails in ages so walking through the Learn Ruby on Rails tutorial which is excellent. I'm having issues with google authentication, the example code calls the config/secrets.yml variables (which are read from ENV in the shell) from the app/models/contact.rb model update_spreadsheet method below def update_spreadsheet connection = GoogleDrive.login(Rails.application.secrets.gmail_username, Rails.application.secrets.gmail_password) I have the ENV variable set via my ~/.bash

404 not found error for assets in rails 4 production enviroment

狂风中的少年 提交于 2019-12-10 23:01:38
问题 I am new to rails from java enviroment. I have few confusions in asset pipeline with rails 3 to 4. Currently I am in rails 4.2.5 I created a sample app on my local environment. I created a new js from inside app/assets/javascripts and referencing it from the view , everything seems to working fine on my local environment. After this I thought to test with production env how it works. Here are the steps I did. RAILS_ENV=production rake assets:clean assets:precompile [All the files created

Devise wrong number of arguments (2 for 1) upon session_controller#create

孤街醉人 提交于 2019-12-10 21:14:09
问题 I'm trying to login with the default activeadmin email - admin@example.com and password - password but when i click login i get the error `wrong number of arguments (2 for 1)` # POST /resource/sign_in def create self.resource = warden.authenticate!(auth_options) set_flash_message(:notice, :signed_in) if is_flashing_format? sign_in(resource_name, resource) #ERROR SHOWING AT THIS LINE yield resource if block_given? respond_with resource, location: after_sign_in_path_for(resource) end May i know

Rails 4.1.2 - to_param escapes slashes (and breaks app)

谁说我不能喝 提交于 2019-12-10 13:20:08
问题 I use in my app to_param to create custom URL (this custom path contains slashes): class Machine < ActiveRecord::Base def to_param MachinePrettyPath.show_path(self, cut_model_text: true) end end The thing is, that since Rails 4.1.2 behaviour changed and Rails doesn't allow to use slashes in the URL (when use custom URL), so it escapes slashes. I had such routes: Rails.application.routes.draw do scope "(:locale)", locale: /#{I18n.available_locales.join("|")}/ do resources :machines, except:

Rails asset pipeline: how to create custom manifest file

丶灬走出姿态 提交于 2019-12-10 12:35:51
问题 I am trying to make a custom manifest javascript file seperate from application.js. I've take the code from application.js and pasted it into a new file I've called "other_manifest.js" and placed in the assets/javascrips directory. Here is the code: // This is a manifest file that'll be compiled into application.js, which will include all the files // listed below. // // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, // or vendor/assets

Undefined method attr_accessible error for User

眉间皱痕 提交于 2019-12-10 09:28:23
问题 I'm trying to create a login of sorts. I created a User scaffold and have this code in my user.rb class User < ActiveRecord::Base attr_accessible :name, :password_digest, :password, :password_confirmation has_secure_password end I keep getting this error undefined method `attr_accessible' for #<Class:0x396bc28> Extracted source (around line #2): 1 2 3 4 5 class User < ActiveRecord::Base attr_accessible :name, :password_digest, :password, :password_confirmation has_secure_password end Rails

Negate ActiveRecord query scope

别来无恙 提交于 2019-12-10 02:29:05
问题 I have a slightly complicated scope on a model class Contact < ActiveRecord::Base scope :active, -> { where(inactive: false) } scope :groups, -> { where(contact_type: 2308) } scope :group_search, -> (query) do active.groups.where("last_name LIKE '%' + ? + '%'", query) end end For testing purposes, I want to make sure that all Contacts not returned by group_search are excluded for the right reasons. But to get that list, I have to load Contact.all - Contact.group_search('query') which runs two

Rails 4 upgrade JSON::ParseError for old sessions

梦想与她 提交于 2019-12-09 15:06:36
问题 After upgrading to Rails 4.1.4 from Rails 3.2, accessing the application with an existing session (from the older Rails 3.2 version) causes an internal server error. backtrace: JSON::ParserError - 795: unexpected token at { I"session_id:ETI"%fa78a4ee07ac952c9b034ebc6199f30b;': /Users/.../.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/json/common.rb:155:in `parse' actionpack (4.1.4) lib/action_dispatch/middleware/cookies.rb:388:in `load' actionpack (4.1.4) lib/action_dispatch/middleware/cookies.rb:428

ActionController::UrlGenerationError in Devise::Registrations#create

泄露秘密 提交于 2019-12-08 11:37:21
问题 I'm newbie in Rails and I don't know what to do with tis error, please help (with explanation): ActionController::UrlGenerationError in Devise::Registrations#create Showing /home/ubuntu/workspace/mamchut418/app/views/devise/mailer/confirmation_instructions.html.erb where line #5 raised: No route matches {:action=>"create", :confirmation_token=>"24GGcednzrEXEzaR82AC", :controller=>"devise/confirmations"} missing required keys: [:locale] Extracted source (around line #5): 3 | <p><%= _('You can