2013年10月10日のブックマーク (6件)

  • layer8.sh

    This domain may be for sale!

    azihsoyn
    azihsoyn 2013/10/10
  • Nested attributes unpermitted parameters

    I have a Bill object, which has many Due objects. The Due object also belongs to a Person. I want a form that can create the Bill and its children Dues all in one page. I am trying to create a form using nested attributes, similar to ones in this Railscast. Relevant code is listed below: due.rb class Due < ActiveRecord::Base belongs_to :person belongs_to :bill end bill.rb class Bill < ActiveRecord

    Nested attributes unpermitted parameters
    azihsoyn
    azihsoyn 2013/10/10
  • Deletion of nested attributes does not work

    I seem to be unable to delete items using the accepts_nested_attributes_for command but I have done this according to this tutorial and the associated git repo. My models are ... class Job < ActiveRecord::Base has_many :specialties, :inverse_of => :job accepts_nested_attributes_for :specialties, allow_destroy: true, :reject_if => :all_blank end class Specialty < ActiveRecord::Base belongs_to :job,

    Deletion of nested attributes does not work
    azihsoyn
    azihsoyn 2013/10/10
    “Unpermitted parameters: _destroy”
  • has_manyな関連先をまとめてINSERTする - Aerialarts

    fields_for、accepts_nested_attributes_forを使って、has_manyな関連先をまとめてINSERTする方法。ソースはgithubに上げておいた。ちなみにRails 3.0.8。 Post has_many Tags through Taggingsというモデルがあったとする。 とりあえずscaffoldはこんな感じ。Taggingだけは画面が要らないのでmodelだけ。 $ rails g scaffold posts title:string text:text $ rails g scaffold tags name:string $ rails g model tagging post:references tag:references $ rake db:migrate コードの修正で重要なのは次の2点。 app/models/post.rb

    azihsoyn
    azihsoyn 2013/10/10
    “fields_forのなかでidも指定してればUPDATEも走らせてくれる。”
  • Rails3系のtimezoneの扱いに関するメモ - Qiita

    ローカルタイムに関する設定 Rails3系からデータベースにはUTCで保存、取り出して扱う際に必要なタイムゾーンに変更するというのが基的な考え方の様子。 タイムゾーンの設定はapplication.rbにて行えるが、主に関係する設定が2つある。 config.active_record.default_timezone config.time_zone config.active_record.default_timezone データベースに保存する際のタイムゾーンを指定するディレクティブ。先ほど書いたようにRails3からはデータベースに時刻を保存する場合は基的にUTCで保存するようになったみたいで、これをローカルタイムで保存するには以下のように設定すれば良い。

    Rails3系のtimezoneの扱いに関するメモ - Qiita
    azihsoyn
    azihsoyn 2013/10/10
  • よく使うgemコマンドのオプション | TECHSCORE BLOG | TECHSCORE BLOG

    こんにちは、鈴木です。 最近は Gem ライブラリの管理は Bundler で行うことが多いですが、Gemfile に書く時に、 「あのライブラリの正しい名前はなんだっけ?」 「このライブラリの今のバージョンはなんだっけ?」 となることが多いのです。みなさんも同じでしょうか・・?(^^; そんな時は gem コマンドを使用して検索することが多いです。 今回はよく使う gem コマンドのオプションをまとめようと思います。 Gemライブラリを探す Gem ライブラリを探すときは「gem search ...」を使用するのですが、なにはともあれ -r オプションを付けます。 -r はリモートリポジトリから検索するためのオプションで、これを付けないとローカルが検索対象になります。

    azihsoyn
    azihsoyn 2013/10/10
    “# ^ と $ を用いることで完全一致検索ができます. > gem search -r ^rails$”