ruby-on-rails

How to auto generate Rails REST API documentation for controllers?

How to automatically generate API documentation for Rails REST controller? Is there any example I can look into using RDoc to do this? ...

(Ruby,Rails) CRUD nested models more than 4 levels deep on a single page...?

Hi All, As much amazing info as is out there, it often seems to fall just short of my demented requirements. That said, I'm looking for a mechanism by which to handle multiple nested models on a single page. Now, I've seen all the videos and posts (not really, but humor me) on nesting two models (Railscasts, etc.). However, I need to...

What should I learn? Python or Ruby?

Possible Duplicate: Should I learn Ruby or Python? Hi guys. I am a PHP developer so, mainly a web developer, and I'm used to work with MVC. I use CakePHP, which is a powerful PHP framework to develop web apps and such. I'm comming from the web scene and I really want to keep my work on the web but I also would like to learn a n...

Rspec integration tests without cucumber?

Is there a way to do integration tests with Rspec without using Cucumber? I prefer using just plain old Webrat. Thanks. ...

Get the SQL that would be executed from a certain method or named_scope

Given an ActiveRecord method or named_scope chain, is there a way to return the SQL that will get executed, without actually running it? e.g. Vote.positive.count.sql #=> "SELECT COUNT(*) FROM votes WHERE value > 0" Is there a built-in way to do this or a plug-in that offers this functionality? If not, any clues to where I can start t...

rails models

i have a model named test.rb and when i use @tests=Test.new in my controller i get the following error. Can someone temme how can i resolve this? "undefined method `new' for Test:Module" ...

Can I call REST web services from Windows Mobile app

Hello, I would like to build a simple REST web service (using Ruby on Rails). However, I would like to be able to call this service from a Windows mobile app. Is that possible? or do I have to use SOAP? I don't have much experience with Windows Mobile apps so it would be nice if you can provide pseudo code or link to tutorial for the p...

how can I simply merge a hash into a new one?

I have a simple hash like so { "1234" => "5", "2345" => "6" } How can I create a new hash with both the keys and values in side it? Like so: { key_id = "1234", value_id = "5" }, { key_id = "2345", value_id = "6" } ...

sending mail to a configured smtp server

I have folowing configuration lines written in mailer.rb file to send mails using a particular sever. config.active_record.default_timezone = :local config.action_mailer.smtp_settings = { :address => "abcprojsmtp", :port => 25, :authentication => :login } config.action_mailer.delivery_method = :smtp config.action_mail...

How to use rails to find this result across 3 tables ?

A project has 3 tables : client, invoices, deliveries The relations are: client has_many invoices client has_many deliveries invoices belongs_to client deliveries belongs_to client Both invoices and deliveries model have a date field. Now I want to find all clients who has a...

How do I check if it returns a null?

i should check whether there is some values based on this condition. if there is some, then i should do one action or else do a different action. i work on rails, mysql and xp this is not working @test.nil? suggest me a alternate way @test=Model.find(:all,:conditions=>"id=@someid")thanks in advance ...

Rails application.html.erb?

The old Rails used to have an application.rhtml file. The newer version appear to have .html.erb files for each model. What's the reason there is currently no application.html.erb file? ...

Converting a Ruby String into an array.

I have a string "1,2,3,4" and I'd like to convert it into an array: [1,2,3,4] How? ...

Website security question with PHP? (Probably applies to ASP/Rails/etc.. too)

Say, I have "index.htm" and "routines.php". "index.htm" will call eventually call "routines.php" using JS (AJAX). So, my question is, how can "routines.php" verify that the request came from the same local server and not outside? Is there a global variable I can check at PHP level or HTTP level? Edit 1: Using AJAX ...

Ruby on Rails Country/State Select Enigma

I am trying to implement something seemingly very simple, and I have been beating my head against it for days at this point. My desired end result is a Country select drop-down, tied to a State select drop-down, in such a way that when a given country is selected, IF states are known THEN those states are displayed in a select drop down...

Flickr gem : how to access user details?

http://github.com/ctagg/flickr/tree/master I'm trying the example in the home page of the flickr gem. require 'flickr' flickr = Flickr.new('MY_KEY') user = flickr.users('[email protected]') user.name user.location while I'm able to get the user object, I can't get any of the other attributes like...

Ruby on Rails: what does "equals" symbol mean as a parameter?

Some open source I've been using has the below line as a function declaration: def parse_query(query=nil, options={}, models=nil) What effect do the "equals" symbols have on the statement? Does it just make the parameters optional? ...

How do you iterate over active record objects in Ruby On Rails?

This question is quite simple but I have run into the problem a few times. Let's say you do something like: cars = Vehicle.find_by_num_wheels(4) cars.each do |c| puts "#{c.inspect}" end This works fine if cars is an array but fails if there is only one car in the database. Obviously I could do something like "if !cars.length.nil?...

How do I add switches to a custom Rails generator?

Part of the generator I am writing isn't needed in all circumstances, so I need to add a switch so that I can specify whether it is run - something similar to the --skip_migration switch. How should I go about implementing this? ...

rails: how to link values in data migrations to class/model variables?

my sql DB contains tables "jobs" and "job_categories." "job_categories" associates job category strings (i.e. "Software Development") with an integer number (i.e. 7). I need these associations saved into variables in my job controller for various query functions. How can I use rails to dynamically link changes to the job_categories tab...