Displaying 2 results from an estimated 2 matches for "required_field".
2011 Jul 15
3
Ruby variable that embeds html tags
This seems very simple, but I can''t quite get it. Probably because I''m
just starting out with RoR.
My view has a slew of labels and text fields; many are "required":
<%= f.text_field :screen_name %> <span class="required_field">Required
field</span>
(The "required_field" class turns the text red and smaller.) I''d like
to not have everything between <span> and </span> sitting at the end
of every required line. I''d like instead to use a variable:
<% req = "<...
2005 Feb 28
5
Using session data in model
...t of the gender, there''s
different fields that needs validation. I''m wondering what''s the
preffered way of doing this. The session data is not present in the
model, i.e:
class Myclass < ActiveRecord::Base
belongs_to :member
def validate
errors.add_on_empty %w{ required_field } if @session["member"].gender
== ''m''
end
end
does not work since the @session["member"] variable is not set. I''ve
tried to set:
@member = @session["member"]
in my controller before I call Myclass.save and that doesn''t seem to...