Warning: Undefined array key "HTTP_REFERER" in /home/u522501990/domains/makemeengr.com/public_html/wp-content/themes/generatepress/generatepress.theme#archive on line 43

skip certain validation method in Model

Update your model to this class Car < ActiveRecord::Base # depending on how you deal with mass-assignment # protection in newer Rails versions, # you might want to uncomment this line # # attr_accessible :skip_method_2 attr_accessor :skip_method_2 validate :method_1, :method_3 validate :method_2, unless: :skip_method_2 private # encapsulation is cool, so we are cool # custom … Read more

Counter Cache for a column with conditions?

With regards to the conditions with counter_cache, I would read this blog post. The one thing you should do is add the following to the migration file: add_column :employees, :projects_count, :integer, :default => 0, :null => false Employee.reset_column_information Employee.all.each do |e| Employee.update_counters e.id, :projects_count => e.projects.length end So you current projects count can get migrated … Read more

Rails.cache error in Rails 3.1 – TypeError: can’t dump hash with default proc

This might be a little verbose but I had to spend some time with the Rails source code to learn how the caching internals work. Writing things down aids my understanding and I figure that sharing some notes on how things work can’t hurt. Skip to the end if you’re in a hurry. Why It … Read more

Ruby 1.9.2 and Rails 3 cannot open rails console

Apparently ubuntu and ruby don’t always catch dependencies like they should. From the first google hit (yeah, I clicked on this stack-overflow in place #2 before checking out the first result.) Navigate to the Ruby source and enter: sudo apt-get install libreadline5-dev cd ext/readline ruby extconf.rb make sudo make install So, if you’re on another … Read more

Why isn’t self always needed in ruby / rails / activerecord?

This is because attributes/associations are actually methods(getters/setters) and not local variables. When you state “parent = value” Ruby assumes you want to assign the value to the local variable parent. Somewhere up the stack there’s a setter method “def parent=” and to call that you must use “self.parent = ” to tell ruby that you … Read more

How to access instance variables in CoffeeScript engine inside a Slim template

What’s happening is that “#{@user_name}” is being interpreted as CoffeeScript, not as Ruby code that’s evaluated and injected into the CoffeeScript source. You’re asking, “How do I inject a Ruby variable into my CoffeeScript source?” The short answer is: Don’t do this. The Rails team made an intentional decision not to support embedded CoffeeScript in … Read more

techhipbettruvabetnorabahisbahis forumutaraftarium24edueduedueduseduedueduedueduedu