Created
February 26, 2012 06:48
-
-
Save richardsondx/1914520 to your computer and use it in GitHub Desktop.
Assign a value to a param, from 2 choices.
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 new | |
@micropost = Micropost.new(:tag => '4' ) | |
# Change the value of 'Micropost.find(..).to_guys' to True or False depending on what button was pressed | |
if request.post? | |
if params[:name].include?( 'to_guys' ) | |
@micropost.to_guys = true | |
flash[:notice] = 'This post was sent to guys' | |
else | |
@micropost.to_guys = false | |
flash[:notice] = 'This post was sent to girls' | |
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
class CreateMicroposts < ActiveRecord::Migration | |
def change | |
create_table :microposts do |t| | |
t.boolean :to_guys | |
t.string :tag | |
t.boolean :approved | |
t.string :content | |
t.timestamps | |
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
<%= form_for @micropost do |f| %> | |
<p> | |
<fieldset> | |
<legend> Enter something </legend> | |
<%= f.text_field :content, :size => 90 %> <br/> | |
<%= f.label "Send to who?:" %> | |
<%= submit_tag "to Guys", :name => "to_guys" %> | |
<%= submit_tag "to Girls", :name => "to girls" %> | |
</p> | |
</fieldset> | |
<% end %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment