ruby-on-rails

RadRails is very slow on Windows 7.

Hi, I'm trying to use RadRails on Windows and it's works relatively smoothly. But, when i hit F5 in my browser i have to wait ~15 secondes to refresh the page. It's annoying because the CPU usage is around 5% and it's looks like RadRails is doing nothing, no debbuger activity, no sql connection and no server requests during the 15 seco...

Nested Has Many Through Plugin and Named Scopes

I have a User Model(:name, :password, :email), and Event model(:name, :etc) and Interest model (:name) [>all singular<] Then I created two join tables -> UsersInterests and EventsInterests; each not containing a primary key and only comprised of the user_id/interest_id and event_id/interest_id respectively. [>plural<] My Models Use the...

Deploy rails app to non-root context - restful_auth not working

I'm running a rails app on http://www.naildrivin5.com/scalatour. It works fine. When I log in to the app using restful_authentication, I get taken to the http://www.naildrivin5.com instead of the app. Weird. This seems like I've misconfigured something. Further, there's a few places where I'm hand-creating some urls, and I need ac...

Javascript Error in IE Using the Prototype library in Rails

I'm running a Rails app and using prototype. The script breaks in IE, but works in all other browsers. I appreciate any help in guiding toward a fix for this. Here's the problem: My users sell products and varieties of products. The varieties available are dependent on the product. For example, if we're talking about fruit, the user ...

Ruby on rails nested form model

Hi all, I'm trying to use rails nested form_for helper, but I am getting the following error: BlogPage(#49859550) expected, got Array(#31117360) Here are my model objects: class Blog < ActiveRecord::Base # Table Configuration set_table_name "blog" # Model Configuration belongs_to :item has_many :blog_pages accepts_nested_att...

Rails: Alternative ways to serve multiple layouts? e.g. iphone.example.com vs. example.com/iphone

I can use this method to signal an alternative layout. someformat.example.com but when I cache that it will be in, for example public/someformat Why involve DNS and the web server if I don't have to? Is there a way to make a Rails app just stay in a url subdir, i.e. to make all url generation relative? I'm attempting this for a Fa...

Formtastic Time fields to read as HH::MIN(00 & 30) instead of two selects?

I'm looking for a way to override the Formtastic plug-in in rails so that times are shown as a single drop-down with minutes represented in half hour increments. Instead of the two drop-downs one for hour and one for minutes. Ex 1:00 AM, 1:30 AM, 2:00 AM, etc? any help would be appreciated. ...

Rails Error When Trying To Mail to Multiple Users

I am trying to use the Whenever plugin for rails to perform a model process at certain times. When I try to use the mail_out process in my User model, I get the following error. Can someone please point me in the right direction of what is going wrong? /var/lib/gems/1.8/gems/rails-2.3.5/lib/commands/runner.rb:48: /var/lib/gems/1.8/gem...

How would dependency injection fit in into Page object model

Does anyone know how dependency injection would fit in into page object model. Say I am extracting all objects from a given page of a web application product. And now I was to define a subclass inside this page class. How would dependency injection would help me here? How should I go about it ? class MyPageClass > SuperPageClass obje...

Create missing auto increment attribute with rails migration

I'm writing a migration to convert a non-rails app into the right format for rails - one of the tables for some reason does not have auto increment set on the id column. Is there a quick way to turn it on while in a migration, maybe with #change_column or something? ...

Rails nested form with has_many :through, how to edit attributes of join model?

How do you edit the attributes of a join model when using accepts_nested_attributes_for? I have 3 models: Topics and Articles joined by Linkers class Topic < ActiveRecord::Base has_many :linkers has_many :articles, :through => :linkers, :foreign_key => :article_id accepts_nested_attributes_for :articles end class Article < Active...

Composite primary keys in Ruby on Rails

I cannot get the composite_primary_keys gem to work with my database. I have the following database tables: mysql> describe currencies; +-----------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------+--------------+------+-----+---------+-------+ | curr_code | varchar...

String to Array and Hash with Regexp

Hi, I would like to turn a string with opening hours like this: "Monday-Friday>10:00-18:00;Saturday>12:00-17:00;Sunday>12:00-15:00" Into this: [ {:period => "Monday-Friday", :hours => "10:00-18:00"}, {:period => "Saturday", :hours => "12:00-17:00"}, {:period => "Sunday", :hours => "12:00-15:00"} ] I'm trying it with the String.sca...

Create a text file on client-side programatically

We have a Ruby-on-rails server-side deployment that needs to allow users to download a pre-compiled self-extracting Windows EXE file on their computer. We also need to generate a text file dynamically (based on the users id) and deploy it somewhere on the client machine where the EXE can find it. We have 2 options: Generate this tex...

Sharing model definitions between Erlang and Rails (and mongodb)

I have a rails app using mongodb through mongomapper and all is well. The problem is... I'm going to want to use erlang to do some background processing and I want to update the same mongo/mongomapper models with the results of this processing. What's the best way to share model definitions between the two apps (rails and erlang) and rem...

rspec testing a controller post changing my params from symbols to strings and breaking my tests

In my controller spec I am doing this: it "should create new message" do Client.should_receive(:create).with({:title => 'Mr'}) post 'create' , :client => {:title => "Mr" } end ... and in my controller I am doing ... def create client = Client.create(params[:client]) end However this is failing with the following error message...

Passing hidden invitation token field after being redirected from openid authorization

I'm trying to combine Ryan Bates' Beta invitations and Open id. The way it is setup is so that signup form has hidden field, invitation token that allows user to sign up. The invitation token is sent in url: /signup/:invitation_token However when I use open_id, it redirects back to just /signup url without the invitation token. How do I...

How to show an animated spinner while a background task is processing in nested rails model using ajax

My specific example is highly complex, so I will use the example shown by Ryan from Railscasts to discuss this: http://railscasts.com/episodes/197-nested-model-form-part-2 Background I have a form, let's say "Survey", which contains an arbitrary number of "Questions". Senario Give i am on the "Edit Survey" page. I would like to add...

How can Ruby on Rails help to embed video to the pages?

Is there any helper (perhaps, an interface to some other video embedding framework) that can be given a filename (of a local file) and would then yield HTML/Flash/something else that shows basic video player? It shouldn't be an interface to youtube or something like that. The video should be hosted at the server I'm developing. ...

User Mailer Failing

I have setup a process in my User model to send a bunch of @users to a mailing script, user_mailer.rb I am using the http://postageapp.com app to send out emails. The users are getting to the User_mailer but I am getting an error from there. Can anyone please point me in the right direction. User Model: class User < ActiveRecord::Base...