Hi,
I'm trying to refactor some code..
if session[:image_subject_id].blank?
if @profile.image_subject_id.blank?
session[:image_subject_id] = nil
else
session[:image_subject_id] = @profile.image_subject_id
end
end
if session[:image_subject_id].blank?
if @profile.image_book_id.blank?
session[:image_book_id] = nil
else
session[:image_book_id] = @profile.image_book_id
end
end
...
...
...
Trying the following:
["image_subject_id", "image_book_id",
"image_chapter_id",
"image_section_id""image_subsection_id",
"image_minisection_id"].each do
|k|
if session[":#{k.to_s}"].blank?
if @profile.k.blank?
session[":#{k.to_s}"] = nil
else
session[":#{k.to_s}"] = @profile.k
end
end
end
Problem is @profile.k gives error NoMethodError: undefined method `k'
for #<Profile:0x00000106da5e60>
k does evaluate to "image_subject_id", so not sure what is wrong...
Thanks
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/3219d860353cd46dcd441f8cb2a4c0e5%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.