ruby-on-rails

how to access javascript variable in rails view

Is there any way to access javasript variable inside the rails view. I just set some value of javascript variable and want to access it in rails view. Thanks ...

rails nested attributes

I am using rails 3.0.0.beta3 and I am trying to implement form with nested attributes using :accepts_nested_attributes_for. My form is nested to three levels: Survey >> Question >> Answer. Survey has_many Questions, and Question has many Answers. Inside the Survey model, there is :accepts_nested_attributes_for :questions and inside...

Rails 2.3.5 model name translation problem in error messages

Hi Rails'ers, I encountered some problem while trying to translate my model's names and attributes in a Rails 2.3.5 app. I have the following model: class BillingPlan < ActiveRecord::Base validates_presence_of :billing_option_id belongs_to :order belongs_to :user belongs_to :billing_option end When validation fails, my m...

How to set I18N locale as condition in a simple full text search in Ruby on Rails ?

Hi, Here is my simple text search code: def search @cart = find_cart @products =Product.find(:all, :conditions => ["title LIKE ? || body LIKE ? || maker LIKE ?", "%#{params [:search]}%", "%#{params[:search]}%", "%#{params[:search]}%"]) if @products.size ==0 flash[:notice] = "Please check the spelling " end I would like to a...

Show or hide fields depending on the Acl9 role - Ruby on Rails

Hi, I am using Acl9 to manage the roles and I want to hide the checkbox usertype if the user has the role :customer and show it if the role is :manager. I want that just the :manager can edit all the fields and some for the :customer. Thank you for your help! <h1>Editing user</h1> <% form_for(@user) do |f| %> <%= f.error_messages %...

Reopen SASS Mixins

Hi, Is there a way to redefine SASS mixins. I want to override SASS mixins for site specific styling needs. Is there a way to do it ? ...

Using rails plugin auto_complete

Hi, i am using the rails plugin auto_complete http://github.com/rails/auto_complete. I have followed the examples, and its all working well, but with one small problem. After submitting an auto completed text field, and then hitting the back button, the text field does not retain the previously selected value. Does anyone have a soluti...

How to redirect to another page using a select menu and link_to - Ruby on Rails

Hi, I want to use a select menu to redirect to another page but when I select 'Home' it doesn't redirect me to the main page. Nothing happens... <select> <option>Select a menu</option> <option><%= link_to 'Home', '/' %></option> </select> Thank you for your help. ...

rails backgroundjob running jobs in parallel?

I'm very happy with By so far, only I have this one issue: When one process takes 1 or 2 hours to complete, all other jobs in the queue seem to wait for that one job to finish. Worse still is when uploading to a server which time's out regularly. My question: is Bj running jobs in parallel or one after another? Thank you, Damir ...

Anyone know of a decent editable combo box plugin?

I'm seeing a couple online but the sites that these guys have look like crap so I don't know if I want to use their plug-ins. If you USE an editable combo box in your web app and you LIKE the plugin then post it here. Please explain why you chose it over other plugins. Edit: Bonus points for anyone who is using it with Rails and can sh...

ruby-on-rails: use vendor/gems on certain machines

I have a couple of different machines I work on: my mac book winxp machine linux server (shared server at hosting corp.) I unpack the gems and dependencies. I use bluecloth. Unpacked Bluecloth on mac & linux works well, no issues. But does not work at all on the winxp box. The only workaround I have is to delete the bluecloth fo...

rails: date type and GetDate

This is a follow up to this question: http://stackoverflow.com/questions/2930256/unique-responses-rails-gem I'm going to create an index based on the user id, url and a date type. I want date type (not datetime type) because I want the day, the 24 hour day to be part of the index to avoid duplication of page views counts on the same da...

New to Rails. Doubt in Big URL Routing

Hi, I have just started learning ruby on rails. I have a doubt wrt routing. Default Routing in Rails is :controller/:action/:id It works really fine for the example lets say example.com/publisher/author/book_name Could you tell me how do you work with something very big like this site http://www.telegraph.co.uk/sport/football/leagues...

Why am I getting a permission denied error on my public folder?

Hi all, This one has got me stumped. I'm deploying a Rails 3 app to Slicehost running Apache 2 and Passenger. My server is running Ruby 1.9.1 using RVM. I am receiving a permission denied error on the "public" folder in my app. My Virtual Host is setup as follows: <VirtualHost *:80> ServerName sharerplane.com ServerAlias www....

Initialize virtual attributes

I have an IncomingEmail model with an attachments virtual attribute: class IncomingEmail < ActiveRecord::Base attr_accessor :attachments end I want the attachments virtual attribute to be initialized to [] rather than nil so that I can do: >> i = IncomingEmail.new => #<IncomingEmail id: nil,...) >> i.attachments << "whatever" W...

Can't get birthday from Google Contacts Data API in Ruby on Rails

I am trying to get a user's contact's birthdays, from Google's data API using the gdata gem. But even though I use the full feed, it does not include the gContact:birthday element. I have also tried fetching only one contact, but the birthday element is still missing. ...

rails smart collection

What are rails smart collections? If I am trying to build a view that presents most popular articles, top 10 products, recent comments (i.e a snapshot of recent updates to a variety of models in one view), would I be using a smart collection? Would I be updating it via something like delayed job? Use some sort of fragment caching? Wha...

Filtering Questions (posts) by tag_name in TagController#index passing /tags?tag_name=something

I am trying to get my TagsController#index action to display only the Questions that contain certain tags when passing the search parameter tag_name. I am not getting an error just can't get the filter to work correctly such that upon receiving the /tags?tag_name=something url, only those questions are displayed . Here is the setup: cla...

Parsing and validating arbitrary date formats in ruby (on rails)

I have a requirement to handle custom date formats in an existing app. The idea is that the users have to do with multiple formats from outside sources they have very little control over. We will need to be able to take the format and both validate Dates against it, as well as parse strings specifically in that format. The other thing is...

auto_complete plugin error: Couldn't find Question with ID=auto_complete_for_...

I have successfully set up this plugin before so I am curious as to what I am doing wrong here. I have built the ability for users to add tags to questions. I am not using tagging plugin here but that shouldn't matter for this. With respect to the auto complete, I am trying to have the form located in the /views/questions/show.html.erb...