Last active
August 29, 2015 14:03
-
-
Save msadoon/706a1b8ee7a30ed40371 to your computer and use it in GitHub Desktop.
updating one record in a db
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def update | |
d { @help } | |
respond_to do |format| | |
if @help.update(help_params) | |
format.html { redirect_to @help, notice: 'Help was successfully updated.' } | |
format.json { render :show, status: :ok, location: @help } | |
#redirect_to action: "index" | |
else | |
format.html { render :edit } | |
format.json { render json: @help.errors, status: :unprocessable_entity } | |
#redirect_to action: "index" | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% @help = Help.find_by_id(1) %> | |
<%= bootstrap_form_for(@help) do |f| %> | |
<% if @help.errors.any? %> | |
<div id="error_explanation"> | |
<h2><%= pluralize(@help.errors.count, "error") %> prohibited this tax rate from being saved:</h2> | |
<ul> | |
<% @help.errors.full_messages.each do |message| %> | |
<li><%= message %></li> | |
<% end %> | |
</ul> | |
</div> | |
<% end %> | |
<%= f.hidden_field :id %> | |
<div class="field"> | |
<%= f.text_field :gst, label: "GST", :min => 0 %> | |
</div> | |
<div class="field"> | |
<%= f.text_field :qst, label: "QST", :min => 0 %> | |
</div> | |
<div class="actions"> | |
<% d { @help } %> | |
<%= f.submit 'Update Help', :class=>"btn btn-success navbar-btn" %> | |
</div> | |
<% end %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment