argument-error

Argument Error: The scope body needs to be callable

点点圈 提交于 2020-01-10 07:19:13
问题 I'm working through the 'Ruby On Rails 3 Essential Training' and have received a problem when using name scopes. When finding records and using queries withing the Rails console everything went smoothly until I tried to use a name scope in my subject.rb file. This is my code in the subject.rb file. Class Subject < ActiveRecord::Base scope :visible, where(:visible => true) end I saved the .rb file and restarted my Rails console but when I run from my rails console: subjects = Subject.visible I

ArgumentError: wrong number of arguments (given 1, expected 2) for Update_Attribute Method

南楼画角 提交于 2020-01-06 06:43:26
问题 I am creating a recurring event app where certain users (streamers) can schedule recurring weekly events (streams) and other users (viewers) can follow them. The result is a personalized weekly calendar detailing when all followed streamers' events begin and end. However, because viewers can follow an infinite number of streamers and therefore the resulting calendar would look like a hot mess. So I added a boolean attribute to the relationships table that indicates whether the relationship

ArgumentError in Rails

拥有回忆 提交于 2019-12-24 06:55:28
问题 I want to connect two entity (project and issues) and Rails says some error message, but I don't know, what should I do. Can you help me fix it, please? Thanks a lot. 回答1: Not sure what your are trying to do, but it looks like you have a nested resource and therefore want to pass an array to form_for , but you are actually passing two separate objects. Change: <%= form_for(@project, @project.issues.build) do |f| %> to: <%= form_for([@project, @project.issues.build]) do |f| %> With this change

invalid byte sequence in US-ASCII (Argument Error) when I run rake db:seed in Rails

这一生的挚爱 提交于 2019-12-18 10:01:36
问题 When I run rake db:seed in my Rails app, I'm getting this error: invalid byte sequence in US-ASCII (Argument Error) I just added science_majors and down to my seed file, and now when I run rake db:seed it gives me this error: invalid byte sequence error Why is this, and how can I fix it? part of seeds.rb @college = College.find_or_create_by_name!('University of Pittsburgh') if @college.update_attributes( url: 'university-of-pittsburgh', public: 'Public', years: '4-year', category: 'National

Ruby `split': invalid byte sequence in UTF-8 (ArgumentError)

故事扮演 提交于 2019-12-04 15:45:52
问题 I am trying to populate the movie object, but when parsing through the u.item file I get this error: `split': invalid byte sequence in UTF-8 (ArgumentError) File.open("Data/u.item", "r") do |infile| while line = infile.gets line = line.split("|") end end The error occurs only when trying to split the lines with fancy international punctuation. Here's a sample 543|Misérables, Les (1995)|01-Jan-1995||http://us.imdb.com/M/title-exact?Mis%E9rables%2C%20Les%20%281995%29|0|0|0|0|0|0|0|0|1|0|0|0|1|0

Ruby `split': invalid byte sequence in UTF-8 (ArgumentError)

吃可爱长大的小学妹 提交于 2019-12-03 09:47:59
I am trying to populate the movie object, but when parsing through the u.item file I get this error: `split': invalid byte sequence in UTF-8 (ArgumentError) File.open("Data/u.item", "r") do |infile| while line = infile.gets line = line.split("|") end end The error occurs only when trying to split the lines with fancy international punctuation. Here's a sample 543|Misérables, Les (1995)|01-Jan-1995||http://us.imdb.com/M/title-exact?Mis%E9rables%2C%20Les%20%281995%29|0|0|0|0|0|0|0|0|1|0|0|0|1|0|0|0|0|0|0 Is there a work around?? I had to force the encoding of each line to iso-8859-1 (which is

Ruby on Rails 5.0 upgrade not working with rails console or db:migrate

孤街醉人 提交于 2019-12-01 06:50:46
问题 After recently upgrading to Ruby on Rails 5.0 from 4.2, I have been unable to run rake db:migrate, or rails console. I think it best to solve the console error first and it seems to give the followin more informative errors: Here is the full stack trace if I correctly understand your request. Thank you. $ rails c /Users/my_username/.rvm/gems/ruby-2.3.0/gems/actionpack-5.0.0/lib/action_controller/test_case.rb:49:in `initialize': wrong number of arguments (given 0, expected 2) (ArgumentError)

invalid byte sequence in US-ASCII (Argument Error) when I run rake db:seed in Rails

佐手、 提交于 2019-11-29 19:13:48
When I run rake db:seed in my Rails app, I'm getting this error: invalid byte sequence in US-ASCII (Argument Error) I just added science_majors and down to my seed file, and now when I run rake db:seed it gives me this error: invalid byte sequence error Why is this, and how can I fix it? part of seeds.rb @college = College.find_or_create_by_name!('University of Pittsburgh') if @college.update_attributes( url: 'university-of-pittsburgh', public: 'Public', years: '4-year', category: 'National University', calendar: 'Semester', location: 'Pittsburgh, PA', setting: 'Large City (250-500k)',