Skip to content

Instantly share code, notes, and snippets.

@richardsondx
Created March 12, 2012 14:56
Show Gist options
  • Save richardsondx/2022465 to your computer and use it in GitHub Desktop.
Save richardsondx/2022465 to your computer and use it in GitHub Desktop.
When I try to submit the form from the _form2 view,the content of the file is empty as if the program didn't recognize the ":commit => "to girls"
<div id="box">
<div id="sticker"><%= image_tag("home_sticker.png")%></div>
<div id="maintextbox">
<%= form_for @micropost do |f| %>
<%= f.text_field :content, :size => 90 , :class => "inputtext", :name => "content", :align => "top", :type => "submit-content"%> <br/>
</div>
<div id="button">
<span id="buttonleft"><%= submit_tag( '#{image_tag("home_button_men2.png", :width=>70)}', :name => "to Guys", :class => "but1", :commit => "to Guys" ) %></span>
<span id="buttonright"><%= submit_tag('#{image_tag("home_button_men2.png", :width=>70)}',:name => "to Girls", :class => "but2", :commit=> "to Girls") %></span>
</div>
<% end %>
<div id="box">
<div id="sticker"><%= image_tag("home_sticker.png")%></div>
<div id="maintextbox">
<%= form_for @micropost do |f| %>
<%= f.text_field :content, :size => 90 , :class => "inputtext", :name => "content", :align => "top", :type => "submit-content"%> <br/>
</div>
<div id="button">
<span id="buttonleft"><%= submit_tag( '#{image_tag("home_button_men2.png", :width=>70)}', :name => "to Guys", :class => "but1", :commit => "to Guys" ) %></span>
<span id="buttonright"><%= submit_tag('#{image_tag("home_button_men2.png", :width=>70)}',:name => "to Girls", :class => "but2", :commit=> "to Girls") %></span>
</div>
<% end %>
<%= form_for @micropost do |f| %>
<p>
<fieldset>
<legend> What's your Tip? </legend>
<%= f.text_field :content, :size => 90 %> <br/>
<%= f.label :tag %>
<%= f.select( :tag, [['#texting', 1], ['#dating', 2], ['#sex', 3], ['#beauty', 4]]) %>
<%= f.label "Send this Tip:" %>
<%= submit_tag "to Guys" %>
<%= submit_tag "to Girls"%>
</p>
</fieldset>
<% end %>
<%= form_for @micropost do |f| %>
<p>
<fieldset>
<legend> What's your Tip? </legend>
<%= f.text_field :content, :size => 90 %> <br/>
<%= f.label :tag %>
<%= f.select( :tag, [['#texting', 1], ['#dating', 2], ['#sex', 3], ['#beauty', 4]]) %>
<%= f.label "Send this Tip:" %>
<%= submit_tag "to Guys" %>
<%= submit_tag "to Girls"%>
</p>
</fieldset>
<% end %>
def new
@micropost = Micropost.new(:tag => '4' )
end
def create
@micropost = Micropost.new(params[:micropost])
if params['commit'] == "to Guys"
@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
<span id="containerright">
<div class="logo"><%= image_tag("home_logo.png")%></div>
<% @micropost = Micropost.new %>
<%= render :partial => 'microposts/form2', :locals => { :micropost => @micropost } %>
</div>
</span>
<span id="containerright">
<div class="logo"><%= image_tag("home_logo.png")%></div>
<% @micropost = Micropost.new %>
<%= render :partial => 'microposts/form2', :locals => { :micropost => @micropost } %>
</div>
</span>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment