how to disable select option in rails?
<%= f.select :action_item_status, action_item_status, {}, {:disabled => true} %>
<%= f.select :action_item_status, action_item_status, {}, {:disabled => true} %>
Current versions of rails support json serialisation out of the box. Define your field as a string (or text) in the migration and then: class Foo < ActiveRecord::Base serialize :field, JSON end bar = Foo.new bar.field = [1,2,3] bar.save
From Googling around, it appears that render will also be called at some point .. but with no template, will cause an error. The solution seems to be to stub it out as well: controller.stub!(:render)
You can set the user agent from an alias a = Mechanize.new a.user_agent_alias=”Mac Safari” Available aliases are stored in the AGENT_ALIASES constant. p Mechanize::AGENT_ALIASES Otherwise, use #user_agent to set your custom user agent. a = Mechanize.new a.user_agent=”Custom agent”
Try with: def show @topic = Topic.find(params[:id]) @posts = @topic.posts.page(params[:page]).per(2) end And then: <%= paginate @posts %>
Solved via this stackoverflow answer I’ve changed my response = Net::HTTP.start(url.host, url.port) {|http| http.request(request)} line to be response = Net::HTTP.start(url.host, url.port, :read_timeout => 500) {|http| http.request(request)} and this seems to have got around this problem.
Try this: def foo_list items content_tag :ul do items.collect {|item| concat(content_tag(:li, item))} end end
According to the documentation OpenSSL::HMAC.digest Returns the authentication code an instance represents as a binary string. If you have a problem using that maybe you need a hex encoded form provided by OpenSSL::HMAC.hexdigest Example key = ‘key’ data=”The quick brown fox jumps over the lazy dog” digest = OpenSSL::Digest.new(‘sha256’) OpenSSL::HMAC.digest(digest, key, data) #=> “\xF7\xBC\x83\xF40S\x84$\xB12\x98\xE6\xAAo\xB1C\xEFMY\xA1IF\x17Y\x97G\x9D\xBC-\x1A<\xD8” OpenSSL::HMAC.hexdigest(digest, … Read more
This tutorial is an excellent example – and it’s Rails 3 Update: This article is a better example than the one I posted earlier, works flawlessly Second Update: I would also recommend merging-in some of the techniques outlined in this railscast on the active_attr gem, where Ryan Bates walks you through the process of setting … Read more
Well, after some digging, it actually is really simple. Just need to run the following. Rails.application.eager_load!