ruby-on-rails-3.2

How to get a Date from date_select or select_date in Rails?

耗尽温柔 提交于 2019-11-26 10:58:16
问题 Using select_date gives me back a params[:my_date] with year , month and day attributes. How do get a Date object easily? I\'m hoping for something like params[:my_date].to_date . I\'m happy to use date_select instead as well. 回答1: Using date_select gives you 3 separate key/value pairs for the day, month, and year respectively. So you can pass them into Date.new as parameters to create a new Date object. An example date_select returned params for an Event model: "event"=> {"name"=>"Birthday",

Using turbolinks in a Rails link_to

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-26 10:43:45
问题 Just wondering whether there\'s a way to use turbolinks directly in a rails link_to helper, a quick bit of googling didn\'t uncover anything of note, here\'s the type of thing I\'ve tried to no avail. <%= link_to \'Giraffe\', giraffe_path(@giraffe), :data-no-turbolink => \'true\' %> <%= link_to \'Giraffe\', giraffe_path(@giraffe), :data { :no-turbolink => \'true\'} %> I know you can do it in regular links like this <a data-no-turbolink=\'true\' href=\"/giraffe-130\">Giraffe</a> Right now I\'m

Use rvmrc or ruby-version file to set a project gemset with RVM?

只谈情不闲聊 提交于 2019-11-26 10:05:07
问题 I use RVM, the Ruby Version Manager to specify a Ruby version and a set of gems for each of my Rails projects. I have a .rvmrc file to automatically select a Ruby version and gemset whenever I cd into a project directory. After installing RVM 1.19.0, I get a message You are using .rvmrc , it requires trusting, it is slower and it is not compatible with other ruby managers, you can switch to .ruby-version using rvm rvmrc to [.]ruby-version or ignore this warnings with rvm rvmrc warning ignore

No secret option provided to Rack::Session::Cookie warning?

雨燕双飞 提交于 2019-11-26 07:28:53
问题 I am running Rails 3.2.3, Ruby 1.9 under Fedora 17. I get this warning, when I run rails s , and how do I fix? SECURITY WARNING: No secret option provided to Rack::Session::Cookie. This poses a security threat. It is strongly recommended that you provide a secret to prevent exploits that may be possible from crafted cookies. This will not be supported in future versions of Rack, and future versions will even invalidate your existing user cookies. 回答1: This is a Rails bug, as the subclass is