I am using Rails 4 to make an app. I use simple form for forms.
I am making presenters which display a slightly different label on form inputs.
I'm using them as follows:
In the form:
<%= f.input :description, :as => :text, :label => " <%= @project_presenter.description %> ", :input_html => {:rows => 10} %>
In the presenter:
class ProjectPresenter
def initialize(project, profile)
@project = project
@profile = user.profile
end
def description
if student?
"What does the project involve? "
elsif sponsor?
"Describe the project. "
elsif educator?
"What does the project involve? How will students be involved in the project? "
elsif researcher?
"What's involved in the project? Describe the issues to be addressed."
end
end
When I try this, I get a syntax error pointing at this line:
<%= f.input :description, :as => :text, :label => " <%=
@project_presenter.description %> ", :input_html => {:rows => 10} %>
I think it doesn't want the <%= %> tags around the presenter.
How do you use presenters in forms?
Presenter is defined as:
class ProjectPresenter
def initialize(project, profile)
@project = project
@profile = user.profile
end
def description
....
end
Associations in the user model are:
has_many :articles
has_many :authentications, :dependent => :delete_all
has_many :comments
belongs_to :organisation
has_one :profile
has_many :qualifications
has_many :identities
has_many :trl_assessments, as: :addressable
has_and_belongs_to_many :projects