ruby-on-rails

Why would you want to use the same controller to handle a singular and a plural route?

I'm working on a rails app and using a singular resource. However the controller name for the singular resource is plural. Eg map.resource activity_report expectes the activity_reports_controller. The explanation given in the rails 3 guide is: "... you might want to use the same controller for a singular route and a plural route..." T...

how to access user id value in another controller in ruby on rails

i want to access user login id (whenever he/she loggedin?) in some other controller i tried so many methods ...

ruby on rails and mongo

hi, is there a library like mongoid for rails 2.1 ? thanks ...

Combining conditions in find. (Rails)

Now i am inputting some data from a form and i have a code to search the database inputting several parameters as input conditions. Now if one the parameters is null (i.e) the field is unchecked i need to replace that parameter with something say * so that the search query is unaffected. How would i do that? @report = Problem.find(:all,...

In Rails, I'm getting a NoMethodError when calling function in new model.

I have a model called Action. It looks like this: class Action < ActiveRecord::Base def register_action(email,type) @action = new() @action.guid = "123456789" @action.email = email @action.action = type action.guid if @action.save end end If I try and access this class from my user_controller, I get an err...

How to make a database appear partitioned by some columns with Active::Record

Suppose a column client_id is ubiquitous through out our database, and for a given session or request, we will be 'in the context' of a client the whole time. Is there a way to simulate having each client's data stored in a separate database, while keeping them in the same table for simpler database-management ? What I want is similar ...

How can I add a combo box using RoR helper?

I have a from like this: <% form_for(@user) do |f| %> <%= f.error_messages %> <p> <%= f.label :username %><br /> <%= f.text_field :username %> </p> <p> <%= f.label :email %><br /> <%= f.text_field :email %> </p> <p> <%= f.label :password %><br /> <%= f.password_field :password %> </p> ...

ruby on rails association

how to create dynamic association in rails ...

Coneverting Time in UTC to Pacific time in ruby?

Hi i get a string from a external method with a time and date like so "07/09/10 14:50" is there any way i can convert that time in ruby to 'Pacific US' time knowing its 'UTC' time? with changes accounted for in the date? i.e if the time difference results in the day being different. thanks ...

Ruby on Rails: How do I pass a variable along with f.submit?

title says it all ...

Creating new Rails project with Aptana fails with "/<project name>/public does not exist"

I am using Windows 7 and Ruby 1.8.7. I get the following error message when I start a new Rails project: Problem Occured 'Replace project index file' has encountered a problem. Resource '/Foobar/public' does not exist. (where 'Foobar' is the name of my new project). Any ideas? ...

Ruby on Rails: Is it possible to extend a method without overriding it?

I want to change the redirect on a create method, but I don't want to override the whole thing. like, by default, if create (lets say) exists, it will have something like respond_to do |format| if @user.save(params[:user]) flash[:notice] = 'The user has been updated' format.html { redirect_to :controller => "su...

Is there a more elegant way to do this in Rails (has_one association)

Hey, I'm very new to Ruby and Rails. I was wondering if I was doing this the right way. @user = User.new(params[:user]) @student.user = @user @student.save if @user.save ...rest of the code In my app, a Student has one User, and each User belongs to a Student (think of a User as an Account). The association itself isn't my question ...

Using hyphen in link_to property?

In my Rails app, I need to set a value for a custom data-* attribute on an anchor tag. However, hashes can't have hyphens if I'm not mistaken. I essentially want to do this: <%= link_to 'Example', example_path, :class => 'something', :data-id => '15' %> :data-id is not valid, however. What can I do to work around this? ...

paperclip validations

I would like to validate the presence of a file with paperclip. When I attempt to submit the form it rolls back, but for some reason it goes looking for a create.erb template which does not exist. I don't get any sort of error message either class Image < ActiveRecord::Base has_attached_file :photo, :styles => { :thumb => "100x100#",...

Deploying a Rails app on dreamhost issue

So I'm at a loss with this one. My error is: Missing these required gems: jrails You're running: ruby 1.8.7.72 at /usr/bin/ruby1.8 rubygems 1.3.6 at /home/ryann/.gem/ruby/1.8, /usr/lib/ruby/gems/1.8 Run rake gems:install to install the missing gems. I have unpacked jrails in my vendor directory and frozen my local rails environment. ...

Proper embedded Ruby Code writing

I am trying to write this : %meta{ :name => "keywords", :content => "#{@page_city}, #{truncate_words(@page_keywords, 7) || 'Meta, Words, Are, Dope, For, SEO'}"} Basically it sees if there is a local page that has a page city or keywords and adds those as they meta keywords. If it doesn't, it says the latter. This works, but the onl...

NSTask Until Interrupted Command in Cocoa / Objective-C

Hello, I am trying to use NSTask on to run an ASR Multicast Stream, a Ruby Server Script, etc. Basically, I'm trying to run tasks with NSTask that do not finish running until interrupted, but the problem is that I can't get the NSTask to run in the background. So it ends up just running and holding up the rest of my program. Any help? ...

Why are these named_scopes causing a duplicate INNER JOIN?

I have a Model which I am using to track permissions in a hierarchical organization using the awesome_nested_set plugin. I'm running into a problem where two named_scopes, when chained together, are creating a duplication INNER JOIN. class Group < ActiveRecord::Base acts_as_nested_set has_many :memberships has_many :accounts, :thr...

Using other languages with ruby

Is it possible to use multiple languages along side with ruby. For example, I have my application code in Ruby on Rails. I would like to calculate the recommendations and I would like to use python for that. So essentially, python code would get the data and calculate all the stuff and probably get the data from DB, calculate and update ...