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

link_toタグでブロックをリンクにする方法

%ul %li.float.indextop1 質問 %li.float.indextop2 詳細 %li.float.indextop3 日付 %li.float.indextop4 回答数 .clear %ul - @questions.each do |question| %li = link_to(question) do .float.indexcontent.indexcontent1= question.title[0,17] .float.…

Rails データの初めの数文字を表示させる方法

例:クラス:Question, コラム名:titleのとき初めの17文字を表示するためにはquestion.title[0,17] ほかにクラスを定義することもできる。 参考: Ruby: How to get the first character of a stringstackoverflow.com

views/layouts/application.html.hamlのなか: !!! 5%html%head %title Ibhiroba2 = stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true = javascript_include_tag 'application', 'data-turbolinks-track' => true = csrf_…

hamlをファイルのデフォルトテンプレートにする

gem 'haml-rails' をinstallする config/locales/のフォルダのapplication.rbで: module HamlDemo class Application < Rails::Application config.generators do |g| g.template_engine :haml endmodule HamlDemo class Application < Rails::Application …

expecting end-of-input

=form_for :question, url: question_path(@question), method: :patch do |f| などの関数が閉じられていない。 SyntaxError in QuestionsController#edit syntax error, unexpected keyword_ensure, expecting end-of-input

Hamlでclass名をつける2:submitボタンにつける

エラー:SyntaxError in QuestionsController#create syntax error, unexpected =>, expecting :: or '[' or '.' ...rue_false(( f.submit, :class => "a btn btn-default" ... ^ もとのコード: %p .box_button = f.submit, :class => "a btn btn-default" …