ruby-on-rails

How can I serialize and communicate ActiveRecord instances across identical Rails apps?

The main idea is that I have several worker instances of a Rails app, and then a main aggregate I want to do something like this with the following pseudo pseudo-code posts = Post.all.to_json( :include => { :comments => { :include => :blah } }) # send data to another, identical, exactly the same Rails app # ... # Fast forward to the s...

Freetds forbidding connection when run as sudo

I have a rails app that uses freetds to establish an ODBC connection into a SQL Server Database. This app is on a server running under mongrel, in theory. If I start the app with: sudo mongrel_rails start -e development -p 9000 -d I get S1000 (0) [unixODBC][FreeTDS][SQL Server]Unable to connect to data source However, when run w...

Commit rails 2.3

Hi guy, I'm working to optimize my website in ror. The rails version is 2.3.5. So, I log mysql query. And I see what rails use transaction (begin commit) to create or update object in database. This method use my server resource and I would like to know how I can disable this commit ? I don't find a configuration for this thing. Thank...

Testing an Rspec Controller with assocations

I've got two models: class Solution < ActiveRecord::Base belongs_to :user validates_attachment_presence :software validates_presence_of :price, :language, :title validates_uniqueness_of :software_file_name, :scope => :user_id has_attached_file :software end class User < ActiveRecord::Base acts_as_authentic validates_pr...

Rails image_tag not closing image tag

On a rails project I am using the image_tag to generate my image html elements. <%= image_tag("test.jpg", :alt => "test image") %> is generating <img src="test.jpg" alt="test image"> This is happening throughout my entire rails project. Is there a setting somewhere that someone else set that is causing this? How can I get rails ...

MySQL full-text search in Rails?

When I added search functionality to my first Rails app, I used Sphinx, after reading that using MySQL's built-in fulltext search was a bad idea. While Sphinx works well, it's a bit complicated to set up, and I feel there's too much overload for the simple searching functionality I require in my app. Searches aren't performed very often...

How do you handle RESTful URL parameters in a Ruby on Rails application?

I am dealing with a very simple RESTful Rails application. There is a User model and I need to update it. Rails coders like to do: if @user.update_attributes(params[:user]) ... And from what I understand about REST, this URL request should work: curl -d "first_name=tony&last_name=something2&v=1.0&_method=put" http://localhost:3000/...

auto_complete plugin, can it submit an ID instead of a name?

I went through the railscast for the auto_complete plugin (here: http://railscasts.com/episodes/102-auto-complete-association), and got it working, even though I have a slightly different setup. But here's the trouble: in the railscast, the example is a :belong_to association, and I have a has_many :through. I was using a collection_sel...

Finding symbols API/documentation

Where do I find documentation for what symbols are available (and what they do) for built-in Rails objects like ActionController? I'm on the ActionController::Base API page for rubyonrails.org, but don't see symbols information. I've tried querying Google, but I don't know what keywords to look for besides rails and symbols. Anyone? ...

Rails basics - counting most used values

A widget has_one type, and type has_many widgets. I'd like to count which types are the most commonly assigned to my widgets (top 3 used). What would be the best way to accomplish this? The way I have the database structured is the widgets table has a type_id, which is assigned by a select when creating the widget. I imagined that th...

Do to total the same elemen and to display t with paginating_find?

For example, Test Table |id|name |item_id|num| |1 |apple |1 |1 | |2 |orenge |2 |1 | |3 |orenge |2 |1 | |4 |pear |3 |1 | |5 |apple |1 |1 | ..... In Controller, @items = Test.find(:all, :page=>{:size=>20, :current=>params[:page]}) I use paginating_find plugin. In view, <% @items.each do |item| %...

rails f.label error

<%= f.label :name, 'Name' %> is causing the following error. undefined method `extract_label_options!' for # ...

Problem installing gems for the first time

Hello all, I'm playing with rails for the first time and running into errors with gems. If I enter the command, sudo ./gem install rmagick, I get the following: Building native extensions. This could take a while... Successfully installed rmagick-2.12.2 1 gem installed Installing ri documentation for rmagick-2.12.2... Installing RD...

How do I save statuses as codes in db but map them to meaningful words in rails?

I need some help with this, please ... If I save a transaction status as a code in the db, but I want to translate them to meaningful names how do I do that? Is that even recommended? If no, what would be an alternative to that? For example: in the db the statuses are "S", "P", "A" and in the actual application I'd like to display: "Su...

Rails - How do I use full email addresses without triggering Net::SMTPFatalError?

I am new to rails and using rails-2.3.5 and ruby-1.8.7. Here is my notifier.rb model: # app/models/notifier.rb class Notifier < ActionMailer::Base default_url_options[:host] = "foo.com" #This method sends an email with token to users who request a new password def password_reset_instructions(user) subject "Password ...

Rails ActiveRecord: Is a combined :include and :conditions query possible?

Imagine I have wiki Articles, with many Revisions. I'd like to do a query with ActiveRecord through the database, which only returns those Articles which have Revisions which are updated in the past 24 hours. Is such a thing possible? I'd imagine it'd be something like: Articles.find_all(:include => :revisions, :co...

Nginx Upload Progress Module with Rails and Passenger

I’ve been trying to get the Nginx upload progress module running on WebFaction with Rails and Passenger (using Paperclip to upload to S3). The best result I have come up with so far are that it reports on start and on finish, but nothing in between. The Ajax request to the /progress path is working fine. This is the nginx.conf file I h...

Is it possible to fetch facebook user's profile without logging using facebook connect?

Basically, I want to fetch facebook profile avatars onto my application since I am using their login to create a particular record. How do we display their profile pic without actually forcing the user to connect into facebook to retrieve these pictures? ...

rails object in rescue after transaction failure is saved

i have a transaction to ensure two models get saved at the same time. begin Recipe.transaction do @recipe.save! if @dish @dish.save! end end rescue #save failed flash[:notice] = "recipe.saved = #{@recipe.new_record?}" render 'form' else #save worked flash[:notice] = 'Recipe added.' redirect_to(@recip...

Removing a gem from GemCutter

I want to delete a gem I uploaded to GemCutter. I couldn't find any commands for this. Some time ago there was a blog post stating gem deletion as an upcoming feature. I haven't seen any further official announcements about this feature. Please let me know if there is a way to do this. ...