ruby-on-rails

Fine Grained rest HTTP verbs browser support

Is there any data regarding how browsers actually support rest http verbs (especially PUT, DELETE). This question is mostly motivated by the fact that many sources (such as this stackoverflow answer) inform that most browsers don't suport PUT and DELETE but don't say which. Rails solves this using a patch on the client, and reversing th...

Multiple Rails version in the same machine

I have several very good books like "The Rails Way", "Learning Rails", etc., those which are written for Rails 2.1 or Rails 2.2 But the latest version I am using in my machine for my projects is 2.3.8 I dont want to miss the content in that book. I want to keep multiple versions of rails in my machine and choose the version when I creat...

Rails - is it possible to use ruby code in RJS files?

Is it possible to use ruby code in RJS files? For example, the destroy.js.rjs file if @template == "viewer" page["viewing_registry_#{@viewer_registry.id}"].replace_html :partial => "shared/request_viewer_link" else page["viewer_#{@viewer.id}"].visual_effect :DropOut, :duration => 2.0 flash.discard end This is the RJS file call...

how to convert any audio file to mp3 in rails?

I want to upload any audio file and want the out put in the mp3 formate . Is it possible in rails ? Is there ffmpeg code or any thing that convert any audio file to mp3? if any share ...

Ruby On Rails: Display html source code instead of rendering it

Hello! I have a big problem (even my server's admin seems to have some difficulties to solve it). I used my cpanel (11.25.0-STABLE) to create a new ruby on rails application, which work fine when accessed to its original uri (with port number). To make that uri more "user friendly", I have created a rewrite to access my RoR applicatio...

My web site need to read a slow web site, how to improve the performance

I'm writing a web site with rails, which can let visitors inputing some domains and check if they had been regiestered. When user clicked "Submit" button, my web site will try to post some data to another web site, and read the result back. But that website is slow for me, each request need 2 or 3 seconds. So I'm worried about the perfo...

Adjust routes.rb for method call in Controller

I have an online portfolio created in Rails featuring different projects. I want to be able to filter the projects by keywords. My approach is to define a method for each keyword in the ProjectsController and link the keywords to call the methods. For Example Keyword = graphic_design: <%= link_to 'Graphic Design', :action => "filter_...

How does the Rails' single table inheritance works?

I have a user table, and a teacher that I newly created. The teacher is sub class of user, so, I use scaffold generator to generate the teacher table, than, I modify the model to do teacher is subclass of user. After all that, I did a db:migrate. Then, I go to http://localhost:3000/teachers/new It shows an error: undefined method `te...

Stub with Rspec/Mocha in Cucumber scenarios

Hi. I am using Cucumber as the BDD framework with rspec/mocha mocking. Ideally we would not mock/stub behavior in cucumber specs; however the scenario is exceptional here. To give you the brief idea of problem here; I have two features product feature and cart feature. Cart feature is currently mocking some of the product fetch from 3 ...

Is there anything like DelayedJob, but not use Database

I'm building a web site with Rails, which will do something in the background. I don't want to use DelayedJob, because it needs a database. What I wan't to do is simple: get some data from another site, save the response in the memory, and keep it for 10 minutes. Is there any tools can do this? ...

How to apply different validation rule according to polymorphic association type (Rails)?

I have Rails polymorphic model and I want to apply different validations according to associated class. ...

jQuery autocomplete - How to view item label but submit item value

I am totally new to javascript and am probably biting of more than I can chew, but I am trying to get the jQuery autcomplete widget working on my Rails site. I have a page called "links" where I want to be able to assign a person to a link. Using the autocomplete I should be able to have a textbox that drops down a list of peoples names...

How can I get back the relationship data in RoR?

I have something like this: class Employee < ActiveRecord::Base has_one :office end class Office < ActiveRecord::Base belongs_to :employee # foreign key - employee_id end If I want to edit the employee, at this form what can I fo to edit the office data? <% form_for(@employee) do |f| %> <%= f.error_messages %> ...

Ruby 1.9, Rails 2.3.9 and unicode characters in database and erb views, still a no go?

I have a Rails application running on Rails 2.3.9. It runs fine with ruby 1.8.7. I'm testing it with ruby 1.9.2-head right now. The application loads fine until I try to load a page that relies on a unicode string. Then I get the infamous encoding error: ActionView::TemplateError (incompatible character encodings: UTF-8 and ASCII-8BIT...

How do I tell paperclip to not save the original file?

How do I tell Paperclip not to save the original file when it is uploaded? Or even better, to store a scaled version of the file as the original? ...

Rspec tests hanging with Paperclip

I have a Picture model in my app that uses Paperclip to attach an image to it. The model: class Picture < ActiveRecord::Base has_attached_file :image, :default_url => "/system/:attachment/missing.png", :styles => { :small => "100x100#", :medium => "460x460>", :large => "1024x1024>" } validates_attachment_presence :image validate...

Cucumber features failing "undefined method `Factory'" with bundler, rails 2.3.5

rake cucumber --trace output: /usr/bin/ruby1.8 -I "/home/vadim/.bundle/ruby/1.8/gems/cucumber-0.8.3/lib:lib" "/home/vadim/.bundle/ruby/1.8/gems/cucumber-0.8.3/bin/cucumber" --profile default Using the default profile... ... Given I signed up with "username/[email protected]/password" # features/step_definitions/clearance_steps.rb:13 ...

Ruby On Rails multiple composite primary keys question

I am a new guy in Ruby, and I have tables with these primary keys: transaction_types: transaction_type transaction_headers: transaction_type transaction_year transaction_id transaction_details: transaction_type transaction_year transaction_id city_id ticker_id tickers: city_id ticker_id Of course, those models have other non ...

Installing rails-3.0.0.beta4 , and getting the royal (Errno::ENOENT)

First let me explain that I've created a million lib directories scouring out all the different responses to this same problem but none of them have really done the trick.. I've tried sudo mkdir /opt/local/lib/ruby1.9/gems/1.9.1/gems/rails-3.0.0.beta4/lib sudo mkdir /opt/local/lib/ruby1.9/gems/1.9/gems/rails-3.0.0.beta4/lib sudo mkdir ...

How do I write a conditional redirect into a model's create method, in a Rails app?

I'm allowing users to create a 'Question' from different pages in the app, and want them to be redirected to the right page after the new question is saved. Since one page has a params[:id] and one doesn't, I thought I'd use that to differentiate between the different redirects. Here's what I was trying to do in my Questions controller:...