ruby-on-rails

Reroute old content (.html/.php etc.) to Ruby on Rails

Hi together, I have switched to Ruby on Rails and my current problem is to reroute the old contents like XXX/dummy.html or XXX/dummy.php in RoR. What exactly is the best solution for isolated content (XXX/onlyinstance.html) content which has a internal structure like XXX/dummy1.html, XXX/dummy2.html http://guides.rubyonrails.org/...

single table inheritance: must all classes in hierarchy have same properties?

I have the following class Item < ActiveRecord::Base end class Talk < Item end with the migration class CreateItems < ActiveRecord::Migration def self.up create_table :items do |t| t.string :type t.string :name t.text :description t.time :start_time t.time :duration t.timestamps end en...

What are the current differences between jQuery and Prototype?

I've been building a Ruby on Rails site in recent months and I've only used a small amount of built in JavaScript functions. However I will be doing much more JavaScript development in the coming weeks and months and I am debating on which JavaScript framework to go with. On the one hand jQuery seems to be the more popular one, but then...

Ruby on Rails -HTTP error handling

Hello all, This is my first post here, so I hope that I am posting this question the right place. Otherwise, please let me know so that I know for next time I post here :) I am working on a RoR website and would like to handle server errors (400, 404, 500, etc.) individually. Also, since the website is dynamic I would like to handle th...

email service that lets you programmatically create addresses?

I'm considering adding email addresses to a marketing web app. Currently users are able to sign up and get a subdomain address that they can choose (theychoose.domain.com). So I'm thinking of also offering [email protected] for an email address they can use. I've pretty much decided on sendgrid.com for sending email through the web ...

Rails 2.3: How to access a model's relationships, when hsing fields_for and :accepts_nested_attributes_for

OK, so the relationship is: Program has many :events And each Event belongs to an Organizer (who has_many :events) In a form for Program/edit, I'd like to list the associated events, and with each of those entries, also have access to each Organizer so I can do something like: textfield(event.name) | textfield(event.date) | label(event...

Redirect root url to somewhere else in Rails application

I have routes like this: map.namespace 'prepayments', :path_prefix => '/:locale/prepayments' do |prepayment| prepayment.root :controller => 'login', :namespace => 'prepayments' ... end map.redirect '/', :controller => 'prepayments/login' # this is not working # I tried also map.root :controller => 'prepayments/login' What I wou...

How do I do a parse, lookup, and assign foreign key on a signup page?

Hi, needing some help to just break down the problem. I have new users who will put in User.Email in a signup process. (I am using Ruby on Rails). For any given email, I want to parse out the @domain portion. I then want to find in a different model, Companies, the company_id with the matching column for @domain. I want to return th...

Customize Node Names in Ruby's Builder

I'm building a tool that generates dynamic xml. As a result my Models have pretty generic names: Project has_many :Groups Group has_many :Items has_many :Groups belongs_to :Project Item has_many :Params belongs_to :Group Param belongs_to :Project belongs_to :Group belongs_to :Item So when I build...

How can I log all HTTP requests to rails app in development mode?

I'd like to be able to log all http requests to a rails app, even those to static assets in the public folder. I'd like to do this with a standard rails setup, e.g. using ./script/server, and without installing Apache, etc. I tried wireshark, but it seems like it doesn't track local traffic. I also tried to use the request object, but t...

mocking an error/exception in rspec (not just its type)

I have a block of code like this: def some_method begin do_some_stuff rescue WWW::Mechanize::ResponseCodeError => e if e.response_code.to_i == 503 handle_the_situation end end end I want to test what's going on in that if e.response_code.to_i == 503 section. I can mock do_some_stuff to throw the right type of ...

Issues with displaying validation messages with Nested Forms (Rails 2.3)

I have a nested form, and for the most part it is working great. The only issue that I have is in displaying validiation errors. Consider the following object relationship: a Project has_many :tasks, a Task has_many :assignments if a validation error occurs on an assignment, with <%=project_form.error_messages %> It displays Task Ass...

Metric-Fu/Rcov "No File To Analyze"

I'm trying to get metric-fu running on a rails project I'm working with. Every time it runs the rcov portion of the metrics I get: ** Invoke metrics:all (first_time) ** Execute metrics:all No file to analyze was found. All the files loaded by rcov matched one of the following expressions, and were thus ignored: [/\A\/System\/Library\/F...

Is there a better alternative to this Ruby idiom?

I'm finding myself writing this bit of code in my controllers a lot: params[:task][:completed_at] = Time.parse(params[:task][:completed_at]) if params[:task][:completed_at] Don't get hung up on what I'm doing here specifically, because the reasons change every time; but there are many circumstances where I need to check for a value in...

Replication to a redundant server with Rails?

I'm working on a Ruby on Rails/PostgreSQL web app that a mobile device communicates with. The mobile device has the ability to post to a primary server and geographically redundant secondary server at the same time. I would to replicate my user and profile data from the primary server to the secondary server instantaneously. Is ActiveRes...

How to Rename or Move Rails's README_FOR_APP

When I run rake doc:app in my Rails application root, the API docs are generated using /doc/README_FOR_APP as the home page. I would like to add a .rdoc extention to that file so it is properly rendered on GitHub. Even better, I would like to move it to the app root (/README.rdoc). Is there a way to do this in my Rakefile by modifying th...

301 redirect of entire site in Rails

I am going to move my web application to a new domain name and want to use 301 permanent redirect for all incoming traffic to the old domain name. I was going to use a before_filter in the application controller that does a permanent redirect. I was wondering how exactly I would write this to catch all urls and pass them 'as is' to the ...

Execute a binary file in ruby (on Heroku)

Is it possible to execute a little binary file (required for payment processing) with Kernel#exec from a ruby app hosted on Heroku ? Or do I need to switch to another rails hosting solution ? ...

:foreign_key not requesting from the right column?

I have three models: for the purpose of asking the question, I'll call them posts, containertable1 and containertable2. Basically, the posts table has a column called misc_id, which has the id of an item that is in either containertable1 or containertable2. I tried to set up a foreign key association, but it doesn't seem to fetch from...

Rails - render :action to target anchor tag?

I'm looking to use render like so: render :action => 'page#form' I also tried this: render :template => 'site/page#form' That didn't work either. The form on this particular page is at the very bottom, and if any errors occur on submission I'd hate for the user to be defaulted to the top of the page. I also need to use render (not ...