ruby-on-rails

Rails: Multiple parameters before do?

I have this syntax which works (since it's from the API, pretty much) <% form_tag :action => "whatever" do -%> <div><%= submit_tag 'Save' %></div> <% end -%> and this, which works <%= form_tag({:action => "whatever"}, {:method => "get"})%> Now I have tried to combine them, guessing the syntax. The "get" does not get added ...

File Upload from Flex to Rails 2 server

Is there any way to upload files from a flex app to a rails 2.2 backend when using the default Cookie Session Store? ...

Configuring Ruby On Rails App in a subdirectory under Apache

I've got apache2.2 on windows. I'm trying to serve both subversion (/svn) and redmine (/redmine). I have svn running fine with this config: <Location /svn> DAV svn SVNParentPath C:/svn_repository ... </Location> This is working great--my svn users can hit http://mybox/svn just fine. Now I want to add another directory for a rai...

How do you write a migration to rename a Model and its table in Rails?

I'm terrible at naming and realize that there are a better set of names for my models in my Rails app. Is there a way to use a migration to rename a model and its table? ...

Is it possible to call a MySQL stored procedure from Ruby?

When I try to call a stored procedure from Rails, I get this exception: ActiveRecord::StatementInvalid: Mysql::Error: PROCEDURE pipeline-ws_development.match_save_all can't return a result set in the given context: call match_save_all() from /Users/otto/Projects/Futures/src/pipeline-ws/vendor/rails/activerecord/lib/active_record/con...

Ruby on Rails and MSSQL Server: trying to insert rows with newid() default values.

(this question was originally posted in another forum a few months ago, without getting any answer ... there was no SO at these times!) My first steps in RoR. I baught one of these books talking about Ruby, and Ruby On Rails. Examples are running correctly on MySQL, so I decided to rewrite them for MS-SQL as a good exercice (and as MS...

Simple Rails routing situation

I'm creating a Ruby on Rails app that consists of stories. Each story has multiple pages. How can I set up routes.rb so that I can have URLs like this: http://mysite.com/[story id]/[page id] Like: http://mysite.com/29/46 Currently I'm using this sort of setup: http://mysite.com/stories/29/pages/46 Using: ActionController::Rout...

adding fields to scaffolding RoR

I've done scaffolding using the method described here http://wiki.rubyonrails.org/rails/pages/ScaffoldGenerator However, I want to know what do i do if i want to add more fields AFTER I have ran the ./script/generate scaffolding model> propertyname:string ...

Recurring billing with Rails and ActiveMerchant: Best practices, pitfalls, gotchas?

We are prepping for the release of a large web application that has been in development for the past year. We are about to start the process of integrating ActiveMerchant to handle recurring subscription fees for the service. I am looking for any advice regarding best practices considering our requirements (listed below) and any additio...

Ruby on rails application root

How do I change a rails app so that a controller foo appears as the application root? In other words, right now all the urls look like host.com/foo/... and I'd like to get rid of the foo and have simply host.com/... ...

ActiveMerchant: How to authorise cards when using gateways that do not support the void operation?

I am working on the billing component of a Ruby on Rails application using ActiveMerchant. The payment gateway we have chosen is PaymentExpress. Code examples I am seeing such as the one below, use authorize() and void() to test the validity of a card: def test_card! auth_response = gateway.authorize(100, card) gateway.void(auth_re...

Rails: has_many :through or has_many_and_belongs_to?

I have an app where I want to link an instance of a model to another instance of the same model via another model (i.e. Task1 > Relationship < Task2) and am wondering if I can use has_many :through for this. Basically, the relationship model would have extra information (type_of_relationship, lag) so it would be ideal to have it as a jo...

Netbeans tells me I have the wrong gems version when trying to run a rails app

I have been using Netbeans 6.5 recently - it complains (on startup, and if I try to run a unit test): "Rails requires RubyGems >= 1.3.1 (you have 1.0.1). Please gem update --system and try again." Yet from the command line "gem --version" : 1.3.1 any ideas? why does netbeans not realise I have gems 1.3.1 ? ...

How do I create email with css and images from Rails?

How do you create and send emails from Rails application, that contain images and proper formatting? like the ones you get from facebook and like. ...

How would you tidy up this controller logic?

I've got some logic in a controller that sets a status of an object if certain conditions are met: if params[:concept][:consulted_legal] == 0 && params[:concept][:consulted_marketing] == 1 @concept.attributes = {:status => 'Awaiting Compliance Approval'} elsif params[:concept][:consulted_marketing] == 0 && params[:concept][:consulted_...

Two controllers for one shared view in Ruby on Rails

I have two controllers for two respective models, by example, photos and categories. index and show methods are very similar in each controller, and the views are identical. What is the best method for share the view by the two models? I've though two options: Use a helper. In the helper will put the code for the view, and will call t...

Moving business rules into model

I asked a question earlier which elicited some great responses. Here's the earlier question On the back of some advice given there, I've tried moving the following controller logic if params[:concept][:consulted_legal] == 0 && params[:concept][:consulted_marketing] == 1 @concept.attributes = {:status => 'Awaiting Compliance Approva...

Netflix API, OAuth, and Ruby Issue

Hi, I am trying to use oauth with the rares-branch Ruby gem. I keep getting the error: instance of OAuth::Consumer needs to have method `marshal_load' My code, activate.rb is below. Any thoughts on how to fix this? THANKS! -Henry require 'oauth/consumer' def index @consumer = OAuth::Consumer.new("CONSUMER KEY","CONSUMER SECRET", ...

Trying to remove a has_and_belongs_to_many relationship in rails

So I just started my first rails project yesterday. I had two many-to-many (has_and_belongs_to_many) relationships in my application. I had one between models games and teams and another between models stats and results. This was all working just fine by creating the join table myself with a migration. I then decided that I did not w...

How to limit Phusion Passenger memory usage?

Is there a way to limit the amount of memory Phusion Passenger uses when serving up your app? My host comes by and kills the process after I get a bunch of traffic and so I end up serving up blank pages. Is there anything I can do to say "hey don't use any more than 100Mb and only spawn 3 processes no matter how overloaded the site is"...