Rails form_tag does not send params if disabled: true

Yes, that is the expected behavior. It is probably not mentioned in the Rails documentation because the disabled and readonly control behavior is defined by the W3C spec. See the W3C documentation for Disabled controls, which states “disabled controls cannot be successful”. A “successful” control is defined as being “‘valid’ for submission.” Setting disabled to … Read more

Trying to get a POST to return 400 bad request

The behaviour is as follows: Handling of Unpermitted Keys By default parameter keys that are not explicitly permitted will be logged in the development and test environment. In other environments these parameters will simply be filtered out and ignored. Additionally, this behaviour can be changed by changing the config.action_controller.action_on_unpermitted_parameters property in your environment files. If … Read more

Strange error in rails – missing helper

The problem seems to have been introduced in the latest version of ruby, ruby 2.2.0. Try this experiment: in rails console/or irb: [1] pry(main)>File.expand_path (“./”) => “/users/xxxx/Sites/xxxx” and in the terminal window: ]$ pwd /users/xxxx/sites/xxxx See the different case? If you get that, then deep in the bowels of active support a regex goes south. … Read more

Rails, Devise, Rspec: Undefined method ‘sign_in’

Did you recently upgrade to RSpec 3 like I did? This is from the RSpec 3 documentation: Automatically Adding Metadata RSpec versions before 3.0.0 automatically added metadata to specs based on their location on the filesystem. This was both confusing to new users and not desirable for some veteran users. In RSpec 3, this behavior … Read more

Bootstrap 3+Rails 4 – Certain Glyphicons not working

I had the same problem and found a solution. Full credit goes to Eric Minkel, who wrote a detailed blog post on the topic. I would highly suggest reading it for further reasoning. Edit app/assets/stylesheets/application.css by adding: *= require bootstrap Edit app/assets/javascripts/application.js by adding: //= require bootstrap In config/application.rb, add the following after class Application … Read more

Best way to go about sanitizing user input in rails

TL;DR Regarding user input and queries: Make sure to always use the active record query methods (such as .where), and avoid passing parameters using string interpolation; pass them as hash parameter values, or as parameterized statements. Regarding rendering potentially unsafe user-generated html / javascript content: As of Rails 3, html/javascript text is automatically properly escaped … Read more

Rails 4.2: Internal Server Error with Maximum file multiparts in content reached

It looks like the multipart limit was added in the Rails 4.2 version of Rack (https://github.com/rack/rack/commit/b0b5fb9467e6ed777d3eaf35afc81d758e308aab). The default is 128, which may be too little for your purposes, it was for mine. Setting the value to 0 in an initializer removes the limit and fixes the problem: Rack::Utils.multipart_part_limit = 0 I would suggest tailoring the … Read more

Is “proc” required with conditional before_action/before_filter?

Found it on Rails Guides: http://guides.rubyonrails.org/active_record_callbacks.html#conditional-callbacks Turns out a Proc isn’t always required for it to work. the :if and :unless options, which can take a symbol, a string, a Proc or an Array. So in your case you could probably get away with before_action :check_stuff, if: “Rails.env.production?” Finding things in Rails documentation can be … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)