Module: Formulaic::Dsl
- Defined in:
- lib/formulaic/dsl.rb
Instance Method Summary collapse
- #fill_form(model_name, action = :new, attributes) ⇒ Object
- #fill_form_and_submit(model_name, action = :new, attributes) ⇒ Object
- #input(model_name, field, action = :new) ⇒ Object
- #submit(model_class, action = :create) ⇒ Object
Instance Method Details
#fill_form(model_name, action = :new, attributes) ⇒ Object
3 4 5 |
# File 'lib/formulaic/dsl.rb', line 3 def fill_form(model_name, action = :new, attributes) Form.new(model_name, action, attributes).fill end |
#fill_form_and_submit(model_name, action = :new, attributes) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/formulaic/dsl.rb', line 7 def fill_form_and_submit(model_name, action = :new, attributes) form_action_to_submit_action = { new: :create, edit: :update } fill_form(model_name, action, attributes) submit_action = form_action_to_submit_action[action] || action click_on submit(model_name, submit_action) end |
#input(model_name, field, action = :new) ⇒ Object
14 15 16 |
# File 'lib/formulaic/dsl.rb', line 14 def input(model_name, field, action = :new) Label.new(model_name, field, action).to_str end |
#submit(model_class, action = :create) ⇒ Object
18 19 20 |
# File 'lib/formulaic/dsl.rb', line 18 def submit(model_class, action = :create) I18n.t([:helpers, :submit, model_class, action].join('.')) end |