ruby-on-rails

How do you rate multiple attributes of the same object?

I've not seen this feature as a plug in and was wondering how to achieve it, hopefully using rails. The feature I'm after is the ability to rate one object (a film) by various attributes such as plot, entertainment, originality etc etc on one page/form. Can anyone help? ...

Is it possible to simulate the behaviour of sprintf("%g") using the Rails NumberHelper methods?

sprintf("%g", [float]) allows me to format a floating point number without specifying precision, such that 10.00 is rendered as 10 and 10.01 is rendered as 10.01, and so on. This is neat. In my application I'm rendering numbers using the Rails NumberHelper methods so that I can take advantage of the localization features, but I can't f...

Refactoring routes - serving different layouts

As a Rails NOOB, I started with a routes.rb of: ActionController::Routing::Routes.draw do |map| map.resources :events map.connect 'affiliates/list', :controller => "affiliates", :action => "list" map.connect 'affiliates/regenerate_thumb/:id', :controller => "affiliates", :action => "regenerate_thumb" map.connect 'affiliates/st...

when I am deploy my ror application on production then I am getting following error

in `gem_original_require': no such file to load -- haml (MissingSourceFile) but this gem already istalled. I have also plugin for this path :-/home/techvant/rails_app/techease/vendor/plugins/haml/init.rb this init file having following code : - begin require File.join(File.dirname(__FILE__), 'lib', 'haml') # From here rescue ...

Dynamically Create Virtual Hosts with Rails, Nginx?

I really like Basecamp's idiom of "dynamically" creating custom virtual hosts for clients -- for instance, once a company has signed up they may quickly login to a special URL like: https://mystartup.basecamphq.com/ --which I think is really neat, it segregates multiple organizations nicely within a single application. My question is:...

making a Rails plugin with partials

I followed the Rails guide to make a plugin which makes an acts_as_* with helpers and controllers. I also would like to use partial views. I could not find a way to make the plugin's helpers' render :partial => ... directives search within the plugin's directory structure (e.g. vendor/plugins/<my plugin>/lib/app/views directory. It alw...

Mailing Multiple Users

I already have figured out how to email users on a single basis (someone enters their email address and a mailer model sends that person an email using friend.email (friend being the model and email being the attribute). Now I am trying to send an email to several users. I started writing a process in my User model like below: class ...

javaPOS with RoR

How we can use javaPOS API with Ruby on Rails? Any idea? ...

URL encoded route to Rails controller

I have a URL encoded resource such as: http://myurl/users/Joe%20Bloggs/index.xml This is for a RESTful webservice which uses user logins in the path. The problem is that the controller in rails doesn't seem to decode the %20. I get the following error: ActionController::RoutingError (No route matches "/Joe%20Bloggs/index.xml" with {...

Set-up Many-to-Many in Rails with destroy allowed for only one of the many

I am trying to model a very simple system, but the Rails way of doing this is escaping me. I'd like to have two entities, a User and a Bet. A bet has two users and a user has many bets. I'd like the creating User of the bet to be able to mark it as resolved (do any form of update/delete on it). My initial thinking was to have a User ac...

Include two inputs in same LI element in Formtastic

Using formtastic, I have a quantity field and unit field that asks for the quantity of the item and the unit it's measured in. My problem, is that I would like the unit box to display along side the quantity box. However, because formtastic pust each input in it's own LI element, I can't get them to appear next to each other. Any ideas...

Rspec: Is there a problem with rspec-rails when initializing a controller class with super(args)?

Hi there, I've been using Rspec for a while and for some reason am receiving errors on a controller called ReferencesController. The error says that I have to specify the controller name by either using: describe MyController do or describe 'aoeuaoeu' do controller_name :my I've tried both variations: describe ReferencesC...

bizarre Facebook connect with authlogic problem

I set up a Facebook connecе to my application following the http://github.com/holden/authlogic_openid_selector_example. But I have a strange problem with Facebook Connect on Firefox and Google Chrome browsers, it just will not allow me to authenticate. But on Safari it works perfectly. ...

How should I structure controller actions that share templates?

Let's say I have a User model, and an Invoice model with a belongs_to :user association. Now I'm creating a new action for my InvoicesController, and the view that will be rendered. The view will have a select-element for selecting the user that this invoice will belong to. So I need to fetch those users somewhere; my instinct is to le...

Whenever Plugin Help

I am trying to use the Whenever plugin for rails to perform a model process at certain times. My schedule.rb is as follows: every 1.day, :at => '5:30 am' do runner "User.mail_out" end My model is as follows: class User < ActiveRecord::Base acts_as_authentic def mail_out weekday = Date.today.strftime('%A').downcase ...

Routing generated paths in Ruby on Rails

I'm a beginner in ruby-on-rails and I spent my last hour trying to do the following thing: I have a ruby-on-rails application - the blog with posts and categories. I want to have another URL for the posts (I would like to have http://localhost:3000/news instead of http://localhost:3000/posts) First I tried to replace the controller and...

Error when submitting custom mail process (whenever plugin)

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...

Capistrano configuration

I'm having some issues with variable scope with the capistrano-ext gem's multistage module. I currently have, in config/deploy/staging.rb. set(:settings) { YAML.load_file("config/deploy.yml")['staging'] } set :repository, settings["repository"] set :deploy_to, settings["deploy_to"] set :branch, settings["branch"] set :domain, ...

HABTM Relationship and Named Scopes

I've been working on this for a while now and I cant seem to find where there error. 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 us...

Can I access the id of the parent object inside a named_scope when fetching associated objects with the 'others' method?

Let's say you have two models: articles and comments. class Article < ActiveRecord::Base has_many :comments end You know you can fetch associated comments to an article like this: article = Article.first article.comments # => SELECT * FROM "comments" WHERE ("comments".article_id = 123) Is there a way to explicitly access the arti...