Tag: ruby-on-rails-3.2

Unable to add Impressionist model to Solr

To keep track of unique views I added impressionist gem. The impressions table will grow at a faster rate due to higher traffic. This will cause problems later when I want to show a comparison between consecutive weeks/months. So I thought of linking impression’s model with solr. To implement this I first created a model […]

How to save to Database with associations in rails protecting mass assignment

After trying for few hours I can not save to the database. The context is this: I have two types of users, one for that I only need very basic information [Username, email, password] and another kind of user for who I need a lot of information [age, gender, city and so on] I did […]

Why does Rails demo app give “uninitialized constant ExecJS::RubyRacerRuntime::Context::V8”?

Being new to Rails, I’m trying to get a basic “hello world” app up and running. Specifically the app in chapter 2 of Agile Web Development with Rails. Loading up the hello world page results in the error given in the title. So far I’ve done the following: rails new demo cd demo Added gem […]

CSV read v/s Temp table read from database, optimization of the loop and active record usage . Ruby

CSV parsing of the file was very slow so I was trying to load the file directly in to some temp table in database directly and then doing the computation as below : Earlier it was like this, took 13 mins to add the entries using below method : CSV.foreach(fileName) do |line| completePath = line[0] […]

How to Upgrade Rails to 4.2?

I Want to upgrade my Rails application properly from 3.2.12 to 4.2 … someone send me this link: http://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html at the moment I’m trying to upgrade from 3.2.12 to 4.0 … i’m hanging on step 5.4: Rails 4.0 no longer supports loading plugins from vendor/plugins. You must replace any plugins by extracting them to gems […]

Is there any method to convert boolean variable to integer in ruby

I have a ruby variable ‘is_published’. I want to convert the value in ‘is_published’ to integer. Is there any method in ruby to do that? if is_published == true is_published = 1 else is_published = 0 end The above code works perfectly. Please help if there is any way to do this in a single […]

simple Ruby Input and Output Exercise log

This question is an exact duplicate of: How do I create this File Input and Output assignment in Ruby 1 answer

Add custom user roles spree 1.3.1

I am using spree 1.3.1 and Devise gem for authentication and i need to add a user_role called as “partner” who can see orders in admin area but can’t create/edit/update/delete any of the orders. Thanks in advance

Make output of diff-lcs human readable

I’m using the diff-lcs gem to output a difference between two bodies of html content. Here’s the sample content. Version one: <p>Paragraph one. Sentence one.</p> <p>Paragraph two. Another sentence.</p> <p>Paragraph three. I dare you to change me!</p> Version two: <p>Paragraph one. Sentence two.</p> <p>Paragraph two. Another sentence.</p> <p>Paragraph three. I dare you to update me!</p> […]

How to update multiple columns in Ruby on Rails 3?

Just out of curiosity, is there a way to say this… user.update_column(:field1, true) user.update_column(:field2, true) … in one line in Ruby on Rails? As far as I know an update_columns method does not exist…

Ruby is the best programming language in the world - Ruby on Rails.