Skip to content

Instantly share code, notes, and snippets.

@marklocklear
Last active December 18, 2015 08:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marklocklear/5757086 to your computer and use it in GitHub Desktop.
Save marklocklear/5757086 to your computer and use it in GitHub Desktop.
Summer of Rails
Week 4
>rails g migration add_completed_to_ideas completed:boolean
>
<div class="field">
<%= f.label :completed %><br />
<%= f.check_box :completed %>
</div>
>rails g migration add_range_to_ideas range:integer
<
<div class="field">
<%= f.label 'How succesfull do you think this idea might be?' %><br />
<%= f.label '1=least successful:10=Most likly to succeed' %><br />
<%= f.text_field :range %>
<%= f.select :range, options_for_select(['1', '2', '3']) %><br/>
</div>
>Validations
validates :name, :presence => true
validates :range, :presence => true
validates :range, :numericality => { :greater_than_or_equal_to => 0, :less_than_or_equal_to => 10 }
Week 5
rails g scaffold task name team_members:text notes:text idea_id:integer completed:boolean
rails g migration add_task_to_idea task_id:integer
<div class="field">
<%= f.label :idea_id %><br />
<%= collection_select(:task, :idea_id, @ideas, :id, :name) %>
</div>
i=Idea.first
i.tasks
Idea.where(:range => 3)
Idea.find_by_sql("select * from ideas")
Task.pluck :name
Task.where(:name => 'Brainstorming').exists?
Week 6 (controllers, routing, authentication)
rails g resource user email password_digest
rake db:migrate
add has_secure_password to user model and change attr_assessible to add password & password_conf
create views for users/new.html.erb & add login link to layouts/application.html.erb
*at this point show that you have the 'sign up' link and that it works, but we have not actually added auth to the app itself
rails g controller sessions new
add 'resource sessions' to config/routes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment