ruby-on-rails

Install Rails 3 on OSX with RVM

Trying to install the new Rails 3 release on OSX 10.6. Have never touched Ruby or Rails on this machine since purchased. I was able to get rvm and get Ruby 1.9.2. installed. From there, I am stuck. I tried: rvmsudo gem install rails -v 3.0.0 sudo gem install rails --pre sudo gem install rails sudo gem update rails And I get the sam...

Why was :overwrite_params deprecated in Rails 3

With overwrite_params, I was doing this to prepare a PDF request for a page: url_for(:overwrite_params => {:format => :pdf}) overwrite_params has been deprecated after Rails 2.3.8, is there a reason for this deprecation? What's the standard accepted alternative? ...

rails batch processing questions

In my app a user can set the status of a Post to different flags like 'v' - visible, 'd' - mark for delete etc. These flags are set via controller actions. I have a batch process that runs and cleans all the posts marked for delete. Post.find(:all, :conditions => ['status = ?', 'd']).each do |p| p.destroy end This batch process runs ...

Where should I put a CSV file that I'm using to perform a data migration?

This may well be a duplicate, but I couldn't find anyone asking quite this question. My understanding* is that if I want to migrate data from an outside source to my Rails app's database, I should do so using a migration. It seems from my preliminary research that what I could do is use a tool like FasterCSV to parse a CSV file (for exa...

samba share on rails

I am writing an XML file in rails(running on RHEL) and will then need to post this file across to a windows share. Sambala was installed so that we can SMB to the share, but after running some test code I get the error: uninitialized constant ApplicationController::Sambala samba = Sambala.new( :domain => 'myDOMAIN', ...

Validating boolean value in Rspec and Rails

I'm pretty confused how to validate boolean values in Rspec and Rails. I understand everything except for false and nil are taken as true in Ruby. But when I use MySQL with Rails, it uses 1 for true and 0 for false (if my understanding is correct). I have the following model spec. I'd like to test boolean value for superuser attribute. ...

Factory_girl has_one relation with validates_presence_of

I have 2 Models: # user.rb class User < ActiveRecord::Base has_one :profile, :dependent => :destroy end # profile.rb class Profile < ActiveRecord::Base belongs_to :user validates_presence_of :user end # user_factory.rb Factory.define :user do |u| u.login "test" u.association :profile end I want to do this: @user = Factory...

How to have multiple versions of Ruby AND Rails, and their combinations on Windows?

Since Windows doesn't support rvm (Ruby version Manager), how do we have Ruby 1.8.7, Rails 2.3.8 Ruby 1.8.7, Rails 3.0.0 Ruby 1.9.2, Rails 3.0.0 on the same PC? Virtual machines can be used but it is kind of troublesome. ...

Technically, isn't it "Rails on Ruby" instead of Ruby on Rails?

More and more people just say Rails instead of Ruby on Rails nowadays... and isn't it Rails, which is developed on top of Ruby, so it is really Rails on Ruby? Update: when people say: I am using Rails, that means it is Rails they are using. When people say: I am using Ruby on Rails, that means they are using Ruby that happens to be on ...

Help understanding polymophic associations (rails)

I know there are plenty of resources on this but I'm having a tough time relating any of them to my situation so I was hoping someone could help me clarify how this works: Basically I have a model Action, (which gets created anytime a user does something that affects another user, like commenting on their article or voting on someones p...

web services between rails and j2se

I developed a web site using rails 2.3.8, and a IM server using openfire(java). I want to share some data between them, or exactly rails as provider, openfire as consumer. A possible way is using web service. But it seems that rails 2.x has deprecated the default SOAP support, I installed the gem activewebservice, but there is lack of do...

Undefined method '>>' for class 'Date' in Rails 3 on Ruby 1.8.7/1.9.2

I'm running a Rails 3.0.0 application on Ruby 1.8.7-p174. Everything was going swimmingly until I tried to run some tests: /Users/avand/.rvm/gems/ruby-1.8.7-p174/gems/activesupport-3.0.0/lib/active_support/core_ext/date/calculations.rb:9: undefined method `>>' for class `Date' (NameError) from /Users/avand/.rvm/gems/ruby-1.8.7-p174/gems...

RoR ajax will_pagination

Hi, I'm building a site for posting opinions and I have categories for opinions. When a user click an opinion category, an ajax request is sent to the server. The results are then updated on the page. I'm trying to build will_pagination into the site, but its not set up for ajax. I found this link github, which provides an example bu...

no such file to load -- rmagick

I have following - Gem Version - 1.3.2 Ruby Version - ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux] Rails Version - Rails 2.3.5 ======================== rmagick (2.13.1, 2.10.0) Authors: Tim Hunter, Omer Bar-or, Benjamin Thomas Rubyforge: http://rubyforge.org/projects/rmagick Homepage: http://rubyforge.org/projects/rmagick In...

Api code for getting results from associated tables in Ruby

Hi , I am new to Ruby on rails.. I am trying to write a sample ruby code for the action that i having in my api Blogs. def tag @query_string = "Blogpost.published" if params[:limit] if params[:limit].to_i.class == Fixnum if params[:limit].to_i > 0 @query_string += ".limit(#{params[:limit]})" ...

Rails: GoogleDocs-Style Autosave

I'm trying to build a Rails app in which you can edit the same model from several different locations on the page. I want changes to be saved automatically every X seconds, with an option of manually triggering a save. I have come up with a solution, but it seems very complicated, and I assume other Rails users have already faced simila...

Ruby on Rails: form and radio button question

I have a form around a list of items. I would like to check a radio button on the list and then, after clicking 'Submit', go to the 'Edit' page of the selected item. The problem is that if I am writing something like <%= form_tag edit_item_path %> but Rails complains that I didn't provided a proper id, which in turn is being set on...

Display column name on view if value present in the column -- Ruby on Rails

I have column LTD in my Company model. After retrieving value from model using Company.find If any value is present in LTD column, then I have to display the text "Limited" on the view. I have many columns in the model which are in the abbreviated form and when value is present their long form are displayed on the view. Therefore writi...

Suggestions on Ruby code for API

hi , i am new to ROR i was acually trying to write Ruby code for the api blogs i have written the ruby code as Loading development environment (Rails 2.3.8) >> class Blogpost < ActiveRecord::Base >> has_many :taggings >> has_many :tags,:through => :taggings >> end => nil >> class Taggings < ActiveRecord::Base >> belongs_...

Searchlogic Results Duplicating with Each Association

When I chain searchlogix conditions that associate different tables, the results duplicate. When I chain searchlogix conditions querying fields from a single table, the results work perfectly. Below is an example of chaining conditions across multiple tables (machine belongs to a manufacturer and machine habtm tools and systems). Mach...