ruby-on-rails

Why does the Rails "new" action have an XML format directive?

I'm a newcomer to Rails, and have been following the tutorial on the rails webpage. Using the scaffold instruction to create a "post" model, I found that the new action in the controller has a special directive for XML format: def new @post = Post.new respond_to do |format| format.html # new.html.erb format.xml { render :x...

Ruby library for manipulating existing PDF

I'm searching for a library to edit already existing PDF's and add a watermark to each page, for example. Could also be blank every other page etc. There seem to be a few PDF libraries out there, but only very few of them can edit existing PDF's and I'm a bit lost on which way to go. Any recommendations? Thank you. ...

Where to find documentation for Capybara? [Rails]

I am working with Cucumber and Capybara and am looking to test a basic javascript confirmation box. I am aware Capybara uses Selenium 2.0 (not RC) for its javascript testing. Where can I find the documentation for testing a simple confirm js dialog and other features of capybara + selenium? Thanks! ...

How to test a confirm dialog with Cucumber?

I am using Ruby on Rails with Cucumber and Capybara. How would I go about testing a simple confirm command ("Are you sure?")? Also, where could I find further documentation on this issue? Thank you! ...

A simple factory_girl question

I have two factories (post_factory.rb, comment_factory.rb) in separate files. I'd like to create a bit complex factory, which will create a post with associated comments for me. I created a third file, called complex_factory.rb, and wrote the following code: Factory.define :post_with_comments, :parent => :post do |post| post.after_cre...

Having trouble getting cucumber 6.3 to run on rails 2.3.4

Hi, I am trying to to get cucumber to run with no luck. Here is the error I am seeing: cucumber features Using the default profile... no such file to load -- test/ (MissingSourceFile) /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in gem_original_require' /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in poly...

How to render in rails metal?

Hi I want to use a custom template file which shoud use the base layout file (app/view/layouts/application.html.erb) in a Rails metal code. Can somebody give me some hints what I need to require or how I can do that? ...

Cucumber Record ID

Given the following in Cucumber: Given a car exists with title: "Toyota" And I go to path "/cars" And I follow "Toyota Page" And I should be on path "/cars/CAR_ID" Where CAR_ID is the ID of the car titled "Toyota". How do I figure out that ID? Thanks! ...

Getting Started with Ruby & Ruby on Rails

Some background: I'm a jack-of-all trades, one of which is programming. I learned VB6 through Excel and PHP for creating websites and so far it's worked out just fine for me. I'm not CS major or even mathematically inclined - logic is what interests me. Current status: I'm willing to learn new and more powerful languages; my first f...

In Rails 3, how does one render HTML within a JSON response?

I'm porting an application from Merb 1.1 / 1.8.7 to Rails 3 (beta) / 1.9.1 that uses JSON responses containing HTML fragments, e.g., a JSON container specifying an update, on a user record, and the updated user row looks like . In Merb, since whatever a controller method returns is given to the client, one can put together a Hash, assign...

No action responded to search

i have defined a method called 'search' in my RecipesController which is not private. in routes.rb i have the following: map.connect 'recipes/search', :controller => :recipes, :action => :search i get the following error: No action responded to search. Actions: ... where my method 'search' does not appear in the actions list...

Rails: Using form tags inside lib

So I have this code inside my lib/ folder: class GlobalConfig::SetHelper def self.yes_no_input(configuration) value = configuration.value name = configuration.name "#{radio_button_tag name, true, (value == true), {:id => "#{name}_yes"}} #{label_tag "#{name}_yes", 'yes'} #{radio_button_tag name, false, (value.blank? o...

Checking deployed port in ruby on rails application

Is there an elegant way to check which port you deployed a ruby on rails application using mongrel? I could not find a directive (i.e. such as #{RAILS_ROOT} which contains the root directory of the application) that I can use to perform a check. I need this to do a check since I am deploying the same application on different ports and ...

How can I remove Ruby, Rails & mysql to start the installation process again?

I've been trying to get setup with Ruby on Rails today, but I think I've followed some bad instructions along the way, and nothing seems to work. I've now borrowed the book "Agile Web Development with Rails, Third Edition" from a friend, and want to follow the setup instructions in that. Firstly, do I need to remove what I've setup previ...

yield in ERB without rails

Hi How can I use yield for template inheritance in erb? I want to use erb in a plain ruby CGI script and want to use a base template and subtemplate like it Rails with the application template does. ...

to use umlaut in urls

These days web addresses can also include non-ASCII characters. So every modern browser and webserver is ready to handle UTF-8 URI. There is any "con" to use it today? I mean, a lot of people will say "it will break old browsers, bla bla bla", but since, we assume javascript support, we don't support more IE6, is it ok if i assume that a...

rails routing for index for the controler

I have one controller with few actions. Here is my routes.rb: map.index 'index', :controller => "main", :action => "home" map.root :index map.with_options :controller => 'main' do |main| main.services 'services', :action => 'services' main.portfolio 'gallery', :action => 'gallery' main.about 'about', :action => 'about' ...

FCKEditor in Rails: add ID attribute

I'm using FCKEditor in my Rails app to create HTML forms and it goes very well, except that no ID tag can be filled out. It asks for name and value with the input tags, but not for an ID. Is there a simple way to enable this or to add this manually? Thanks! //Edit: If it's easier: a check that the name attribute has to be unique would b...

rails - Redirecting console output to a file

On a bash console, if I do this: cd mydir ls -l > mydir.txt The > operator captures the standard input and redirects it to a file; so I get the listing of files in mydir.txt instead of in the standard output. Is there any way to do something similar on the rails console? I've got a ruby statement that generates lots of prints (~8k l...

update div after jeditable submit in rails

i want to submit the text from jeditable, store it in the database and then i don´t want to render the updated text back to jeditable field, i want to update the whole div in which the jeditable field (and maybee other text fields) is. f.e. i change the username via jeditable inplace editor, then i store the changes in the db and now...