Repository navigation
Week 1
zurbergram edited this page Oct 23, 2014
·
2 revisions
- What is an application?
- Ruby, RubyonRails, Javascript
- Model-View-Controller (MVC)
- What is Open Source?
- 4-week plan
##Pre-requisites
- Install Rails http://railsinstaller.org
- install Sublime text (or another text editor) http://www.sublimetext.com/
- if a windows user download and install http://nodejs.org/download and reboot!
rails new sw_devcampcd sw_devcamp- For Linux boxes, add to \Gemfile:
- uncomment:
gem 'therubyracer', platforms: :ruby -
bundle install(installs javascript support)
- uncomment:
-
rails s=> Starts the Rails Web Server - open browser, go to http://localhost:3000
- Play!
- press
<control>-cwhhen done
- rails shortcuts - scaffolds
- builds model, view, controller, and tests
- Our first Model: Event
- Meetings, Bootcamps, Camp
- What Fields do we want?
rails generate scaffold Event name:string description:text start_time:datetime end_time:datetime location:text- setup the database:
rake db:migrate - restart the web server:
rails s - open browser, go to http://localhost:3000/events
- Play!
- press
<control>-cwhen done
We want to see what events are available when we bring up the site
- open sublime text and do File - Open:
config/routes.rb - add
root to: "events#index" - run
rails s - open browser, go to http://localhost:3000
- Play!
- press
<control>-cwhen done
- Zurb Foundation
- add to Gemfile:
gem 'foundation-rails' - download it from the internet: 'bundle install'
- set it up:
rails g foundation:install - run
rails s - open browser, go to http://localhost:3000
- Play!
- press
<control>-cwhen done
- Rails Gems
- https://github.com/plataformatec/devise: User management
- add to Gemfile:
gem 'devise' - dowload and install it:
bundle install - run
rails generate devise:install - Create the User form:
- run
rails generate devise User - add User to the database
rake db:migrate - setup so we can e-mail:
- edit
config/environments/development.rb - add the line:
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 } - add a place for error messages:
- edit
app/views/layouts/application.html.erband add after the<body>tag:
<p class="notice"><%= notice %></p>
<p class="alert"><%= alert %></p>
<% if current_user %>
<%= link_to 'Log Out', destroy_user_session_path, :method => :delete %>
<% end %>
- Register a user:
- run
rails s - open browser, go to http://localhost:3000/users/sign_up
- create a user
- And now let's keep people from accessing events:
- add
before_action :authenticate_user!to/app/controllers/events_controller.rb - run
rails s - open browser, go to http://localhost:3000
- Play!
- press
<control>-cwhen done
- Rails Guides: http://guides.rubyonrails.org/
- Ruby on Rails API: http://api.rubyonrails.org/
- Look at gems: http://rubygems.org/
- Rails for Zombies: http://railsforzombies.org/levels/1
- Codeacademy:
- HTML & CSS: http://www.codecademy.com/en/tracks/web
- Ruby: http://www.codecademy.com/en/tracks/ruby
- Javascript: http://www.codecademy.com/en/tracks/javascript