ruby-on-rails

How to create a url for notification in Rails

Hi All, i want to send an email to user after he sign-up with code.for ex http://192.168.1.51:3000/logins/activate/435546dgfd757676657 #link contains in an email how can i create the above URL in my notifier model. i know following way url_for :controller=>'logins', :action=>'activate', :id=>'435546dgfd757676657' , :host=>'http://192...

how to model editing of multiple related resources on the same webpage?

Lets say we have a Company model, that has many Employees And has many Projects If we want to show the projects, we'll go to "/company/1/projects/index" If we want to edit 1 project, we'll go to "/company/1/projects/1/edit" What if we want to edit all the projects at once on the same webpage? We can go to "/company/1/edit" and put a n...

Cucumber steps not automatically loaded when running features

I have recently updated the Cucumber gems ('cucumber' and 'cucumber-rails') on my machine and have run into a couple of issues. The one i am currently fighting is that none of the defined steps for my features are being automatically loaded by Cucumber. This results in my command line telling me i "can implement step definitions for unde...

send application to user Notifications on rails

I'm using the facebooker plugin in rails to let users sign up through facebook connect. the application uses iframe. Now when certain things occur,how can I send notifications to application users from the application through facebook. ...

Creating a new nested resource

I'm working on a basic garden logging application which consists of gardens, plants and planted plants. Each user has one or many gardens, plants are master definitions, and a planted plant can be thought of as an instance of a plant in a specific user's garden. In my routes.rb file I have the following: map.resources :gardens do |gar...

Excess errors on model from somewhere

I have a User model, and use an acts_as_authentic (from authlogic) on it. My User model have 3 validations on username and looks as following: User < ActiveRecord::Base acts_as_authentic validates_presence_of :username validates_length_of :username, :within => 4..40 validates_uniqueness_of :username end I'm writi...

Rails Layout name inside view

How can I print out the name of current layout in a view? Example puts controller.current_layout Thx ...

Rails caches_page :index in Wrong Location

I have a controller Projects in my Rails app with: caches_page :index However, instead of the cached file being generated at /public/projects/index.html it is located at /public/projects.html. The web server (currently Mongrel) looks for */ directories before *.html files. So the http://…/projects request is routed through Rails and ...

Rails - Associations - Automatically setting an association_id for a model which has 2 belongs_to

I have 3 models class User < ... belongs_to :language has_many :posts end class Post < ... belongs_to :user belongs_to :language end class Language < ... has_many :users has_many :posts end Im going to be creating lots of posts via users and at the same time I have to also specify the language the post was written in, wh...

How to performance/benchmark testing a Rails app with real world database?

I would like to performance testing a Rails app. The real world data is 100 MB in size. But Rails always rebuilds the test database, which overwrites the real world data. So how to the performance testing? ...

How to handle session domains in a cname forward supporting rails saas software

Hi, I have read http://stackoverflow.com/questions/975877/how-to-give-cname-forward-support-to-saas- http://stackoverflow.com/questions/377137/rails-multiple-top-level-domains-and-a-single-session-cookie But I am unable to get a solution for the following setup: A SaaS Webapp in Rails is running under example.com All users have a ...

How to cache queries in Rails across multiple requests

I want to cache query results so that the same results are fetched "for more than one request" till i invalidate the cache. For instance, I want to render a sidebar which has all the pages of a book, much like the index of a book. As i want to show it on every page of the book, I have to load it on every request. I can cache the rendered...

Adding a CSS class to the options tag inside a select wrapper w/ Rails

What if I need to add a class to the options tag? <option value="testme1" class="selected">testme1</option> I haven't been able to do this. This is what I have <%= select(:user, :goalstext, Bodytarget.all.collect {|b| [ b.name, b.id ] },{"class", "test"}, :class => "selected", :class => "selected") %> ...

Rails - Whitespace added to content of textarea on save

I'm trying provide a textarea for the user to enter javascript. Each time the form is saved more whitespace is appended throughout the content. Any ideas how to ensure this doesn't happen? Using Rails ...

RoR Server won't detach with -d option

I had to reinstall a bunch of my port installs the other day and now when I launch my RoR server with "ruby script/server -d -p 3000" the server wont work. I am not seeing any errors in the logs. If I start it with "ruby script/server -p 3000" it works fine. Any ideas of what I might have uninstalled that would cause this behavior? ...

Custom form helpers

Is there a way that I can create a custom form helper so that instead of: special_field_tag :object, :method I can achieve something like: form.special_field :method ...

paperclip private files

Is there a way to make paperclip attachments private? As in only where I explicitly want a user to be able to access a file, can the user access the file. Obviously the file can't be in a public directory, but how do I get paperclip to check the user's access rights when trying to access that file to begin with? ...

Background processing in rails

Hi, This might seem like a FAQ on stackoverflow, but my requirements are a little different. While I have previously used BackgroundRB and DJ for running background processes in ruby, my requirement this time is to run some heavy analytics and mathematical computations on a huge set of data, and I need to do this only about the first 15...

Rails 3 Beta 2, Haml, Nested Layouts and LocalJumpError

Alright, I'm trying to create an app with nested templates. I'm using Rails 3 Beta 2 and Haml. I've poked around and I've decided to take the clearest approach and have structured my templates like so: # application.html.haml !!! %body %h1 Outermost Template = yield(:foobar) # inner.html.haml - content_for :foobar do %h2 Inner Te...

Rendering 'belongs_to" in index view question - Ruby on Rails

I have created a simple blog application with Ruby on Rails. The applications consists of two tables, posts and comments. Comments belongs_to :post and posts has_many :comments. I created posts table with the following columns: title:string, body:text. I created the comments table with the following columns: body:text post_id:integer n...