Reputation: 977
Given a Ruby on Rails model that looks like this (db/schema.rb):
create_table "users", :force => true do |t|
t.string "name"
t.string "email"
t.string "other"
end
In the users_controller.rb
I am doing:
def new
@user = User.new
@user.email.downcase!
@user.other = "TEST"
end
and in the show
view (show.html.haml
):
User details:
%b #{@user.name} + #{@user.email} + #{@user.other}
The problem is that the @user.other
value is not displayed at all. My guess is that the @user.other
is nil
, but I don't know why it's not set to TEST
, as I set it in the new
controller action.
In my Users
model, I set:
attr_accessible :name, :email, :other
Any ideas?
Thanks!
Upvotes: 0
Views: 60
Reputation: 38645
new
and show
actions are different. When you set something in new
doesn't mean that it will get shown in your show
view. If you had @user.other = "TEST"
in your create
action then you would have definitely seen "TEST" for #{@user.other}
in your view.
Upvotes: 3