developer

Difference between string and text in rails?

Question: ❓❓❓ I’m making a new web app using Rails, and was wondering, what’s the difference between string and text? And when should each be used? Good Answer: πŸ‘ŒπŸ‘ŒπŸ‘Œ The difference relies in how the symbol is converted into its respective column type in query language. with MySQL :string is Read more…

By admin, ago
developer

How can I set default values in ActiveRecord?

Question: ❓❓❓ How can I set default value in ActiveRecord? I see a post from Pratik that describes an ugly, complicated chunk of code: http://m.onkey.org/2007/7/24/how-to-set-default-values-in-your-model class Item < ActiveRecord::Base def initialize_with_defaults(attrs = nil, &block) initialize_without_defaults(attrs) do setter = lambda { |key, value| self.send("#{key.to_s}=", value) unless !attrs.nil? && attrs.keys.map(&:to_s).include?(key.to_s) } setter.call('scheduler_type', Read more…

By admin, ago
developer

How to disable logging of asset pipeline (sprockets) messages in Rails 3.1?

Question: ❓❓❓ Sprockets tends to be quite verbose in the (dev) log by default under Rails 3.1 (RC1): Started GET "/assets/application.css" for 127.0.0.1 at 2011-06-10 17:30:45 -0400 Compiled app/assets/stylesheets/application.css.scss (5ms) (pid 6303) Started GET "/assets/application.js" for 127.0.0.1 at 2011-06-10 17:30:45 -0400 Compiled app/assets/stylesheets/default.css.scss (15ms) (pid 6303) ... Started GET "/assets/default/header_bg.gif" Read more…

By admin, ago
developer

Rails I18n validation deprecation warning

Question: ❓❓❓ I just updated to rails 4.0.2 and I’m getting this warning: [deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message. Is there any security issue in setting it Read more…

By admin, ago