ruby-on-rails

How to master Ruby on Rails

Hi, I've been using online tutorials to learn ROR. I've used www.lynda.com video lessons to get a basic idea what Rails is all about, and for practice I used Rails version 2.0.2, during my training period. But now I'm into a development team in a starter company where there are no senior/experienced programmers to assist me and we're wo...

validates_one_of

I have a table that contains a column for a boolean value. I want there to be only one row that can have that boolean value be true. Does rails support such a feature? I'm looking for something like the following: Table id | bool_value 1 | false 2 | false 3 | true 4 | false ...

Slow request processing in rails, 'waiting for server' message.

I have a quite big application, running from inside spree extension. Now the issue is, all requests are very slow even locally. I am getting messages like 'Waiting for localhost" or "waiting for server" in my browser status bar for 3 - 4 seconds for each request issued, before it starts execution. I can see execution time logged in log f...

How can I add " " to each item in this collection in RoR?

At the moment, I have this run of code: <%=h current_user.notes.collect { |t| t.name }.join(', ') %> which outputs this: note 1, note 2, note 3 How can I change it so that the output looks like this? "note 1", "note 2", "note 3" Thanks for reading. Edit: Here is the full code of KandadaBoggu's suggestion below $(window).ready(...

scaffolding and updating attributes manually in ruby on rails howto?

Hi, I was wondering if anyone knew how to update the files (adding/removing/updating an attribute) produced by using the scaffold generator in ruby on rails. For example: scaffold student name:string lastname:string so this will create a the associate files (controller,view,etc) with name and lastname as string attributes. When you ...

ruby rails converting params to int array

Hi, I am sending data via get and I need to put it into a int array to be used in a find. here is my code : @found = Array.new params['candidate'].each do |c| @found << c.to_i end My url looks like this http://localhost:3000/export/candidate?candidate[]=3&amp;candidate[]=4&amp;commit=Export If it makes any difference I am u...

Ruby on Rails customer-facing formbuilder?

I have a customer that wants to build their own questionnaires. Something like WuFoo (www.wufoo.com) but more secure and contained within the app. I've looked at Smerf (http://github.com/springbok/smerf) which provides the yaml-to-form conversion, but I'd like something the user can use to create their own forms. ...

Debugging rspec with ruby1.9 and netbeans

Hi, How can I debug rspec specs with an IDE? specifically I'm using the following: * Ubuntu 10.04 * ruby 1.9.2-dev built with rvm * rails3-beta4 * NetBeans 6.9 I have installed the ruby-debug19 and the ruby-debug-ide91 gems, but NetBeans doesn't recognize my fast-debugger. Besides trying to debug a spec in NetBeans gives the follow...

Why does rails generate object instance variables in controllers

Why does rails use @poop object instance variables instead of just a local poop variable in the generated code? Is there some foreseen common situation where it's useful rather than simply using a local variable here? I would think it makes sense to use a local variable and not attach something to the object namespace unless you need it ...

rails - saving data to another controller

Hi, I am trying to receive data at one controller and then save it on another controller/model From the api I wrote the following: class ExportController < ApplicationController def search @assignment = Assignment.find_by_id(params[:assignment_id]) @assignment.candidates.new(params[:candidate_ids]) @assignment.candidates...

Tell AuthLogic to not use a password confirmation

I have this view: new.html.haml %h1 New account - form_for @user do |f| = f.error_messages = render :partial => "form", :object => f = f.submit "Create account" _form.html.haml = form.label :email = form.text_field :email %br/ = form.label :password, form.object.new_record? ? nil : "Change password" = form.password_field :pas...

looking for a good reference for consuming feeds with RoR (Ruby on Rails)

Hey, I'm writing a personal bookmarking application, and looking for a way to keep track of favorite feeds. All written in Rails. Thanks ...

rails 3 validation on uniqueness on multiple attributes

Hi folks, I use Rails 3.0.0.beta4 I want to add a validation on uniqueness on two attributes, that means that my model is valid if the couple of 'recorded_at' and 'zipcode' is unique. On one attribute here is the syntax validates :zipcode, :uniqueness => true thanks ...

How do you structure a restful route with several GET constraints?

Suppose you are working on an API, and you want nice URLs. For example, you want to provide the ability to query articles based on author, perhaps with sorting. Standard: GET http://example.com/articles.php?author=5&amp;sort=desc I imagine a RESTful way of doing this might be: GET http://example.com/aritcles/all/author/5/sort/desc ...

REST/Rails questions - support for HTTP methods?

So I am getting this error for one of my routes. I'am running Rails v2.3.8 + Mongrel 1.1.5. Does rails support only GET & POST?? ActionController::MethodNotAllowed (Only get and post requests are allowed.): The route defined in my routes.rb is - map.connect "#{base_url}/r/:id/rate?v=:value&u=:user_id", :conditions => { :method => :pu...

jQuery matched set to string

I need to serialize a matched set so it's values can be passed to my rails app. The matched set code is (returns the parent div of every uninitialized select element): jQuery('select').filter(function(index){ return jQuery(this).val() == 0;}).closest('div') for serialization I really only need the id of each matched element so I...

Custom error pages in Ruby on Rails

I have this code somewhere in my controller: raise PermissionDenied When this is executed, I want to show a custom error page written in HAML, rather than the default NameError page. Can anyone help me? Thanks. ...

Rails - Missing template users/#<User:0x8334c18>.erb in view path app/views

I'm not sure what I could be doing to get this error. Obviously, I don't think I should be creating the specific file it mentions in my app\views folder. Can anybody point me in the right direction? ...

How to create this Ruby on Rails form?

I have a route that looks like the following: map.newsletter '/newsletter', :controller => "newsletter" , :action => "newsletter_signup" There is also a NewsletterController and a Newsletter model. The thing is, I wanted to keep my controller down to one simple method, newsletter_signup. In there I simply check if the request is of ty...

In a Rails form, how does one create <button>

More specifically, I need to create <button type="submit">Foo</button> type markup in my Rails form. Is there a helper for that? ...