ruby-on-rails

Using instance variable that belongs to a controller class in a Prawn pdf program

I have my controller to generate report using rails Prawn. The problem that i face is, i could only use the argument that is passed while calling the Prawn::Document.generate(a,b,c,d). But i cannot use any instance variable in Prawn pdf program, while that instant variable is in controller class. HOw to use the the instance variable in ...

Passing a form object to a partial rendered from an ajax request

I have an event form with some nested attribute models. The additional models are rendered after a client is selected from a select box. An observer watches and calls a controller action which renders a partial containing the fields_for nested models. The issue I'm having is that I can't pass the event 'form' block to the newly rendered ...

RoR array -count identical elements-on including value

how do we count idential values on after appending value in to array such that a=[] a<<1 count of 1 is 1 a<<1 count of 1 is 2 thanks ...

How do I specify that a named route should use a model's columns its _url and _path functions?

I have a Posts model with id and title columns. I've got my route (rails 2.3.8) set up as follows: map.post ':title/:id', :controller => 'posts', :action => 'show' which works correctly when recognising URLs and when generating them explicitly, as in post_url(:title => 'foo', :id => 123) which comes out nicely as /foo/123. What I...

POST request reaches server but empty

I'm setting up an API for a simple webservice and stumbled upon a problem. I use Ruby on Rails for the back end and a JQuery ajax call to send a POST to create an instance of a model. The JavaScript code is: $.ajax({ type: "POST", url: "http://localhost:3000/api/v1/person/add", data: "name=John&location=Boston", success: funct...

jQuery across models in Ruby on Rails

Hi all! I have this rather simple Ruby on Rails application : two models Lists and Items. Lists have many Items and Items belong to Lists. OK. The show method of ListsController prints a page with the list of the items belonging to the given list (in a partial lists/_listOfItems.html.erb). At the end of the show.html.erb view, there is...

In Rails 2 yielding a block in a helper a method renders partial?

Rails 2.2.2 _competition.html.erb <p>This is packed</p> <% pack do %> // some javascript <% end %> competitions_helper.rb def pack(&block) yield + 'PACKED' end However 'PACKED' does not get appended to my javascript string, its as if pack do has no effect. It seems like there is some oddness going off with context of the blocks ...

responds_to_parent in rails 3

How I will use responds_to_parent plug in rails 3. I had used it in rails 2.3.5. At that time there was no errors. But when I shifted to rails 3 its showing the following error undefined local variable or method `erase_redirect_results'. How to solve this issue? Please help me ? ...

Are there any Rails plugins that allow for Excel-like functionality in the views?

I am looking for a way to allow web users to view tabular information in a view, and interact with the data in a similar way. In other words: Tab through cells Highlight multiple cells Fill multiple cells simultaneously Does such a plugin exist? I have not been able to locate one via search engines. ...

Ruby on Rails 2 - Complex forms for Lesson, Questions & Answers

Hi All, I have 4 models - Users, Lessons, Questions & Answers. Each user can create a lesson with some questions and then ask other users to answer those questions and submit the form. I ran into a problem creating a view to display a lesson with a list of questions and a blank answer field underneath each question. I have a working ...

howto install gems in $HOME instead of "/" with bundler?

by default bundler install gems into system root. but I want to install gems into $HOME. how can I do it? ...

Simple_captcha image not getting displayed

Hi All, Captcha image is not displayed on the ui, instead it just shows simple_captcha.jpg. When i try to access the image through url i get following error:- "Postscript delegate failed /tmp/magick-XXKDifRg': @ error/ps.c/ReadPSImage/779:(null)'" Thanks, Anubhaw ...

RubyOnRails: url_for application root

Hi all, i know that doing url_for(:only_path => false, :controller => 'home') I will get, for example, http://localhost/home But how do i handle to genereate http://localhost ...

How Do I create an .ics file with rails and ri_cal ?

Hi folks, I am using rails 3 and the ri_cal gem. I am not able to produce a valid .ics file. It gets generated, but AppleCalendar or GoogleCalendar say it's empty. What did I do wrong? Help appreciated, thanks in advance :) My Controller class WebsitesController < ApplicationController def index respond_to do |format| f...

Rails MultiSite App + nginx config

I'm trying to deploy a multisite Rails app with different views and public folders for each site. Let's say that we have www.foo.com and www.bar.com. Inside my RAILS_ROOT directory I have a [sites] directory with two folders inside [foo] and [bar] each folder consists of a [public] and [views] folder. My nginx configuration has to be so...

Windows Gem Installation

Hi all, I'm a newbie to Ruby on Rails. I had a quick question about installing gems. I'm using a windows 7 64 bit machine with Ruby 1.9.2 and Rails 3.0 and I'm trying to install the gravatar_image_tag gem. gem install gravatar_image_tag After I run that it says its succcessful. But when I try to do this: gravatar_image_tag -v ...

Not being able to order by includes on Rails3

I have the following expression: user.clocks.includes(:users, :runs => :user_runs).find_by_id(params[:id]) which seems to work fine. But when I add an orders, like this: user.clocks.includes(:users, :runs => :user_runs).orders("users.names").find_by_id(params[:id]) it breaks with the following error: ActiveRecord::ConfigurationErr...

Delayed::Jobs keeps sending emails if it fails..

I used Delayed_Jobs to send emails. Except I think that if it fails to send to 'every single email' then it tries and reruns the entire batch again. How do I make it skip an email address if its not correct? ...

Single technology stack vs. multiple technologies for high scale site

Hello, I have recently been come to for advise on an idea of rewriting an existing site due to massive maintenance problems in their old design. Basically, the company is considering a complete rewrite of aprox. 90% of their site which is currently written in PHP using an in-house framework. The company would like to rebuild the backen...

Grouping a ruby array

I have a ruby array > list = Request.find_all_by_artist("Metallica").map(&:song) => ["Nothing else Matters", "Enter sandman", "Enter Sandman", "Master of Puppets", "Master of Puppets", "Master of Puppets"] and i want a list with the count like this Nothing Else Matters => 1 Enter sandman => 2 Master of Puppets => 3 So ideally i wan...