0

cart.rb

class Cart < ActiveRecord::Base

  belongs_to :user

end

user.rb

class User < ActiveRecord::Base

  attr_accessor :login

  has_one :cart

end

when I create a user in rails console, message:

E:\work\my_store>rails c
DL is deprecated, please use Fiddle
Loading development environment (Rails 4.1.8)
irb(main):001:0> user1 = User.new(login: "user1")
=> #<User id: nil, login: nil, created_at: nil, updated_at: nil>
irb(main):002:0>

Why not login assigned value " login: "user1" " ? Help me to solve this

  • http://stackoverflow.com/questions/15590450/ruby-2-0-0p0-irb-warning-dl-is-deprecated-please-use-fiddle – Misha Jun 08 '15 at 19:50
  • put this `attr_accessible :login` below `attr_accesor` and try to create the record. – Amit Sharma Jun 08 '15 at 20:50
  • `login` is part of your user table attributes? @amit `attr_accessible` is not available anymore in rails 4 http://stackoverflow.com/a/17371364/895789 – Alter Lagos Jun 09 '15 at 14:04

0 Answers0