2015-03-26から1日間の記事一覧

notice、alert 表示

noticeの表示 Settings#editのnotice app/controllers/settings_controller.rb 6 6 def update 7 7 @user = current_user 8 8 if @user.update_attributes(params_user) 9 redirect_to user_url(@user) 9 redirect_to user_url(@user), notice: "プロフィー…

DEBUG model or controller

config/initializers のなかに log_formatter.rbをつくる (内容をこぴぺ) def show loggger.debug params end ほかに、 logger.debug @board.inspect などとする。 ほかに、 def show raise end としてbetter errorsでみる。

logoutしたいとき

Note: method: :delete (:destroyではない!)

Rails 「~さんのページ」と表示したいとき

「~ さんのページ」となってしまう。 コード: %span %h4= @user.screen_name さんのページ エラーになるコード: %h4= @user.screen_name さんのページ NameError at /user.1undefined local variable or method `さんのページ' for #<#<Class:0x007f943901ade0>:0x007f9439739ab8> </class:0x007f943901ade0>…

Rails ログイン時のみの設定 if user_signed_in?

引用: It appears that user_logged_in? Is not used anymore, and instead you need to use user_signed_in? So with the code you gave this should work: <% if user_signed_in? %> <%= render :partial => "home/statusbar" %> <% end %> This code ren…