自分メモ Rails周りでよく使うコマンドとか
ルーティングの確認
[Shell]
[root@www38181u teams]# rake routes
(in /var/www/Teams)
new_user_session GET /users/sign_in(.:format) users/sessions#new
user_session POST /users/sign_in(.:format) users/sessions#create
destroy_user_session DELETE /users/sign_out(.:format) users/sessions#destroy
user_password POST /users/password(.:format) users/passwords#create
new_user_password GET /users/password/new(.:format) users/passwords#new
edit_user_password GET /users/password/edit(.:format) users/passwords#edit
PUT /users/password(.:format) users/passwords#update
cancel_user_registration GET /users/cancel(.:format) users/registrations#cancel
user_registration POST /users(.:format) users/registrations#create
new_user_registration GET /users/sign_up(.:format) users/registrations#new
edit_user_registration GET /users/edit(.:format) users/registrations#edit
PUT /users(.:format) users/registrations#update
DELETE /users(.:format) users/registrations#destroy
team_main POST /team/main(.:format) team/mains#create
new_team_main GET /team/main/new(.:format) team/mains#new
edit_team_main GET /team/main/edit(.:format) team/mains#edit
GET /team/main(.:format) team/mains#show
PUT /team/main(.:format) team/mains#update
DELETE /team/main(.:format) team/mains#destroy
[/Shell]
名前空間つきのコントローラーの作成
[Shell]
[root@www38181u teams]# rails g controller Team::main
create app/controllers/team/main_controller.rb
invoke erb
create app/views/team/main
invoke test_unit
create test/functional/team/main_controller_test.rb
invoke helper
create app/helpers/team/main_helper.rb
invoke test_unit
create test/unit/helpers/team/main_helper_test.rb
invoke assets
invoke coffee
create app/assets/javascripts/team/main.js.coffee
invoke scss
create app/assets/stylesheets/team/main.css.scss
[/Shell]
名前空間つきコントローラーのルーティング設定
[Shell]
namespace ‘team’ do
resources :main
end
[/Shell]
DeviseAPI周り
- ログイン確認
before_filter :authenticate_user!
部分テンプレートにインスタンス変数を渡す
<%= render partial: "japan_select", locals: {city: @city}%>