Created
March 30, 2012 05:47
-
-
Save richardsondx/2246958 to your computer and use it in GitHub Desktop.
I have 2 forms, one using submit_tag and one using image_submit_tag. The controller recognize the params from the first form but not the second.
This file contains 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
<%= form_for @micropost do |f| %> | |
<p> | |
<fieldset> | |
<legend> What's your Tip? </legend> | |
<%= f.text_field :content, :size => 90 %> <br/> | |
<%= f.label "Send this Tip:" %> | |
<%= submit_tag "to Guys" %> | |
<%= submit_tag "to Girls"%> | |
</p> | |
</fieldset> | |
<% end %> |
This file contains 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
<div id="textfield"> | |
<%= form_for @micropost do |f| %> | |
<%= f.text_field :content, :size => 90 , :class => "inputtext", :placeholder => "What's worth sharing?"%> <br/> | |
</div> | |
<span>You have <span id="charsLeft"></span> chars left.</span> | |
<script> | |
$('.inputtext').limit('140','#charsLeft'); | |
</script> | |
<div id="buttons"> | |
<%= image_submit_tag("guys_button.png", :name => "commit", :value => "A", :class => "to_guys")%> | |
<%= image_submit_tag("girls_button.png", :name => "commit", :value => "B") %> | |
</div> | |
<% end %> |
This file contains 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 create | |
@micropost = Micropost.new(params[:micropost]) | |
if params["commit"] == "to Guys" or params['value'] == "A" | |
@micropost.update_attribute(:to_guys, true) | |
flash[:notice] = "to Guys was clicked and the boolean is updated" | |
else | |
@micropost.update_attribute(:to_guys, false) | |
end | |
if @micropost.save | |
redirect_to(:back) | |
flash[:notice] = "Thanks! You have successfully posted this Micropost." | |
else | |
render :action => 'new' | |
flash[:notice] = "Something went wrong. You're Micropost wasn't created" | |
end | |
end |
This file contains 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
<p><%= micropost.content %> + | |
<!- using the value below just to see if it worked--> | |
<%= micropost.to_guys%> </p> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment