I am having errors when using the where method
Project.where('projectid=10').first
It give me this :
NoMethodError: undefined method
where' for #<Class:0xb6ee1144>
from /home/rvb/2011/January/desaldata/vendor/rails/activerecord/lib/active_record/base.rb:1672:in
method_missing_without_paginate'
from /home/rvb/2011/January/desaldata/vendor/gems/mislav-will_paginate-2.3.6/lib/will_paginate/finder.rb:167:in `method_missing'
from (irb):3
I'm using Rails 2.1.1 .. Is the where method not available in this rails version?
'Where' method is only available in rails 3.0.0 or above....
If you do upgrade to Rails (or just ActiveRecord) 3.0, change your query to this:
Project.where(:projectid => 10).first
Also, change the name of 'projects'.'projectid', to 'projects'.'id'.
Related
I'm running into this error when upgrading from Rails 6.0.3 to 6.1:
NoMethodError:
undefined method `assert_nothing_raised' for #<RSpec::ExampleGroups::EmailJob:0x00005572d8a00758>
Did you mean? assert_raises
This happens every time a test calls perform_enqueued_jobs.
I'm using RSpec 3.9.
Apparently assert_nothing_raised is a helper method defined by ActiveSupport. I was able to solve this issue by explicitly including the helper in spec/rails_helper.rb:
RSpec.configure do |config|
config.include(ActiveSupport::Testing::Assertions)
# ...
I am updating from Rails 3 to Rails 4.2, and when I run my application's test suite, I get the following error:
Failure/Error: get 'edit', id: #shops[3].id
NoMethodError:
undefined method `map!' for #<Shop::ActiveRecord_Relation:0x007ff1d69b4f40>
The code in the controller is:
existing_shops.map! { |obj| [["##{obj[:shop_id]} #{obj[:name]},
#{obj[:phone]}, #{obj[:address]}, #{obj[:city]}, #{obj[:state]}, #{obj[:zipcode]} "]]}
I am using Rails 4.2.4 and RSpec 3.3.0.
Relation no longer has mutator methods like #map! and #delete_if. Convert to an Array by calling #to_a before using these methods.
existing_shops.to_a.map! { ... }
— A Guide for Upgrading Ruby on Rails
I am using Kaminari 0.16.3 with Rails 4.2.0. Not sure what is going wrong, I have pasted code run by me in console, which proves kaminari gem is loaded but page method is undefined on ActiveRecord model.
abhishek#abhishek ~/my_app (master●●)$ rails c [ruby-2.1.5p273]
Loading development environment (Rails 4.2.0)
irb(main):001:0> Kaminari
=> Kaminari
irb(main):002:0> User.page
NoMethodError: undefined method `page' for User (call 'User.connection' to establish a connection):Class
Please note: I am intentionally calling page without any arguments to reproduce the issue.
Due to an issue with will_paginate and rails_admin I had this in my codebase causing the page method to be renamed to per_page_kaminari.
I have realized this late and fixed.
Kaminari.configure do |config|
config.page_method_name = :per_page_kaminari
end
Have a look at this tutorial https://github.com/amatsuda/kaminari
This is how it works
User.page(page_number).per(records_per_page)
Where does the call to the isolation_level come from?
My module fails at a.save!
module AppsHelpers
def self.create_app!
a = App.new
a.save!
a
end
end
The specific NoMethodError:
Failure/Error: #app = AppsHelpers::create_app!
NoMethodError:
undefined method `isolation_level' for ActiveRecord::Base:Class
What could possibly cause this failure?
System:
ruby 1.9.3p448
Rails 3.2.8
This was simple. I was calling a method defined in the Transactional Isolation gem: The stacktrace was not helpful because I was calling it from an installed gem and this was a missing dependency.
I'm trying to get the rails-ckeditor gem to work. I followed the instructions on the README.
But I get this error
undefined method `html_safe?' for #<String:0xb6b6d080>
This is my formtastic form code:
<%= f.input :content, :as => :ckeditor %>
Any ideas? Thanks!
UPDATE
I'm using Rails 2.3.8. And here's the stack trace.
/usr/lib/ruby/gems/1.8/gems/ckeditor-3.4.3/lib/ckeditor/safe_buffer.rb:6:in `<<'
/usr/lib/ruby/gems/1.8/gems/ckeditor-3.4.3/lib/ckeditor/view_helper.rb:52:in `ckeditor_textarea'
/usr/lib/ruby/gems/1.8/gems/ckeditor-3.4.3/lib/ckeditor/formtastic.rb:9:in `send'
/usr/lib/ruby/gems/1.8/gems/ckeditor-3.4.3/lib/ckeditor/formtastic.rb:9:in `ckeditor_input'
/usr/lib/ruby/gems/1.8/gems/formtastic-1.1.0/lib/formtastic.rb:1281:in `send'
/usr/lib/ruby/gems/1.8/gems/formtastic-1.1.0/lib/formtastic.rb:1281:in `inline_input_for'
/usr/lib/ruby/gems/1.8/gems/formtastic-1.1.0/lib/formtastic.rb:109:in `send'
/usr/lib/ruby/gems/1.8/gems/formtastic-1.1.0/lib/formtastic.rb:109:in `input'
/usr/lib/ruby/gems/1.8/gems/formtastic-1.1.0/lib/formtastic.rb:108:in `map'
/usr/lib/ruby/gems/1.8/gems/formtastic-1.1.0/lib/formtastic.rb:108:in `input'
/home/shreyas/repos/citymgmt/app/views/articles/_form.html.erb:4
/home/shreyas/repos/citymgmt/app/views/articles/_form.html.erb:2:in `_run_erb_app47views47articles47_form46html46erb_locals_form_object'
/home/shreyas/repos/citymgmt/app/views/articles/_form.html.erb:1:in `_run_erb_app47views47articles47_form46html46erb_locals_form_object'
/home/shreyas/repos/citymgmt/app/views/articles/new.html.erb:10
/home/shreyas/repos/citymgmt/app/views/articles/new.html.erb:3:in `_run_erb_app47views47articles47new46html46erb'
Are you running an earlier version of Rails than 3.0.0? You'll want to install the rails_xss plugin which provides this functionality. In Rails 3, this comes standard.
I would advise, if at all possible, to upgrade to Rails 3 as soon as you are able.
Do you have a stack trace? Based on the error, I'm assuming that the plugin load order is causing a string to not be instantiated with SafeBuffer support (which also leads me to believe you're using Rails 2).
Can you provide some context?