Skip to content

Instantly share code, notes, and snippets.

@jlebrech
Last active August 29, 2015 13:56
Show Gist options
  • Save jlebrech/8863055 to your computer and use it in GitHub Desktop.
Save jlebrech/8863055 to your computer and use it in GitHub Desktop.

Revisions

  1. jlebrech revised this gist Feb 7, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion thing_controller.rb
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@ def update
    @my_form = MyForm.new(params)

    if @my_form.valid?
    McGuffin.create(@my_form.to_hash)
    @mc_guffin.update_parameters(@my_form.to_hash)
    else
    flash.now @my_form.errors
    end
  2. jlebrech revised this gist Feb 7, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion thing_controller.rb
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@ def edit
    def update
    @my_form = MyForm.new(params)

    if @my_form.valid
    if @my_form.valid?
    McGuffin.create(@my_form.to_hash)
    else
    flash.now @my_form.errors
  3. jlebrech revised this gist Feb 7, 2014. 3 changed files with 18 additions and 4 deletions.
    4 changes: 2 additions & 2 deletions edit.html.erb
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,8 @@
    <% @my_form do |f| # custom form %>
    <% @my_form.render do |f| # custom form %>
    <div class="firstname"><%= f.firstname # maybe options are possible here %></div>
    <div class="text"><%= f.text %></div>
    <% end %>
    <%= @my_form # no customization %>
    <%= @my_form.render # no customization %>
    8 changes: 6 additions & 2 deletions my_form.rb
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,11 @@
    Class MyForm < RealForm
    text_area :text, size: 100
    text_area :text, size: 100, label: "Some text", class: "funky class", validate: is_blah_blah

    input :firstname

    password :password
    password :password, id: "the password"

    def is_blah_blah
    ...
    end
    end
    10 changes: 10 additions & 0 deletions thing_controller.rb
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,13 @@
    def edit
    @my_form = MyForm.new()
    end

    def update
    @my_form = MyForm.new(params)

    if @my_form.valid
    McGuffin.create(@my_form.to_hash)
    else
    flash.now @my_form.errors
    end
    end
  4. jlebrech created this gist Feb 7, 2014.
    8 changes: 8 additions & 0 deletions edit.html.erb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    <% @my_form do |f| # custom form %>
    <div class="firstname"><%= f.firstname # maybe options are possible here %></div>
    <div class="text"><%= f.text %></div>
    <% end %>
    <%= @my_form # no customization %>
    7 changes: 7 additions & 0 deletions my_form.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    Class MyForm < RealForm
    text_area :text, size: 100

    input :firstname

    password :password
    end
    3 changes: 3 additions & 0 deletions thing_controller.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    def edit
    @my_form = MyForm.new()
    end