ruby-on-rails

Rails Cache Clearing

Hi Everyone, I have this in my production environment: # The production environment is meant for finished, "live" apps. # Code is not reloaded between requests config.cache_classes = true How do I completely clear the cache so changes I deploy take effect? I have added content to one of the pages but it doesnt seem to show up since ...

Rails Application expecting me to restart my webrick server for any change in my controller.

I am working on an existing Rails 2.3.x application, So I was working on it and it was a messy code with great difficulty I was able to run the application. But now for every small change in one of my controller it is expecting me to restart my serer otherwise the changes are not reflecting back, Let's take an example scenario here, Let'...

Rails - how can I query the db w/o touching the sessions table

Hi - I'm trying to provide a HTTP api to my app that queries a db that's read-only (for replication purposes). I find that my app crashes repeatedly when making a request b/c the call is trying to update the sessions table whenever I query the db. This doesn't happen when I return some text without hitting the database for info. class...

Can some one explain the code snippet given below in ruby ?

class ApplicationController < ActionController::Base class InvalidParam < StandardError;end end What is the reason for including another class inside application controller?? What will be the behavior for other controllers? ...

Start a new project in Rails 3.0 or 2.3?

I'm seeking opinion on this. I'm planning a big project in rails and wanted to get some opinion on whether I should start the project in rails 3.0 or start in 2.3 and convert later when 3.0 is declared stable. I'm new to rails and so after reading of some of the big changes in 3.0, i'm unsure of what would be best. thoughts? ...

Rails : Scaffold works for the first, but not for the second table

I am using aptana radrails empty rail project : scaffold Article titre:string body:text categorie_id:integer ordre:integer Migrate -> it works fine scaffold Categorie titre:string ordre:integer It generate the files but when i access http://127.0.0.1:3000/categories i have the following error : NameError in Categories#index Showing ...

How to send HTML email with styles in rails

I want to know how we can send webpage (HTML page) as an email. I want to add style in a html page like Images or some table formatting. I want to know that should I add style in my "conta.text.html.erb" or I can add CSS in it? ...

Access Rails under /app/, not /app/public/

I'm trying to deploy Rails 2.1.2 with Apache 2.2.10 and FastCGI (yeah, bad, ancient, ugly, I know). And I know it's no programming question, but please bear with me. My application can be accessed via example.com/app/public/, but I want to access it via example.com/app/. In my .htaccess-File (in the app/-directory!) I have: RewriteEng...

Is there any plugin which will help me validate model on client-side?

I need to validate form on client-side and I was wondering if there is a rails plugin which will help me in this task? Maybe it will build javascript needed to validate certain model from ActiveRecord validations? ...

Call more than one item from a different model?

Hi Everyone, At the moment in my application I can select a company from the company model when creating a new kase in the kase model. <ul id="kases_new"> <li>Company<span><%= f.select :company_id, Company.all.collect {|m| [m.companyname, m.id]} %></span></li> This shows a list of the companies and then when I choose one it adds...

Rails, search item in different model?

Hi Everyone, I have a kase model which I am using a simple search form in. The problem I am having is some kases are linked to companies through a company model, and people through a people model. At the moment my search (in Kase model) looks like this: # SEARCH FACILITY def self.search(search) search_condition = "%" + search +...

Cannot render javascript from controller

I want to display a modal window with an error message, when the user has entered something invalid in a form, but render another action if everything is ok. However, when I try to display the modal window with render :js => "jQuery.facebox(#{...})" only the actual javascript called is displayed: try { jQuery.facebox(...) } catch (e...

Ruby on Rails Admin Panel & Site Analytics - What are the options

I have a few apps written in ruby on rails and like any good developer I want high quality data about my site, such as measuring the number of new user accounts per day. I'm in the process of writing my own analytics tools, but I feel like i'm re-inventing the wheel. Are there any plugins or gems that could help me pull this data and dis...

What's the big picture difference between observers and callbacks?

What's the big picture difference between observers and callbacks? When and where to use which one? ...

How do I see the whole HTTP request in Rails

Hi, I have a Rails application but after some time of development/debugging I realized that it would be very helpful to be able to see the whole HTTP request in the logfiles - log/development.log, not just the parameters. I also want to have a separate logfile based on user, not session. Any ideas will be appreciated! Angel ...

Undefined method 'total_entries' after upgrading Rails 2.2.2 to 2.3.5

I am upgrading a Rails application from 2.2.2 to 2.3.5. The only remaining error is when I invoke total_entries for creating a jqgrid. Error: NoMethodError (undefined method `total_entries' for #<Array:0xbbe9ab0>) Code snippet: @route = Route.find( :all, :conditions => "id in (#{params[:id]})" ) { if params[:page].present? the...

Rails STI - Prevent base class from instantiation

Is there any way in a Rails STI situation to throw an error when the base class is Instantiated? Overriding initialize will do it but then that gets trickled down to the subclasses. Thanks ...

Constants in Model and View with select option and show view

i have a some values ,that i use in my model as constants. class Animal < ActiveRecord::Base LEGS = {:vierbeiner => 4, :zweibeiner => 2 } end in the form (formtastic) for the collection i use: <%= f.input :legs, :as => :select, :collection => Animal::LEGS => but how do i format the show view so instead showing me the number , ...

how do i check the value inside a text feild while using ruby selenium testing?

i am running a selenium test using ruby and was wondering how i can assert the value inside a text field? i have a page where once its loaded has text inside the editable text field and i was wondering how i can check if the text is present? thank you ...

How do I specify an action on a resource in a namespace in rails 3?

I have a resource :products in a namespace :shop, like this: namespace :shop do resources :products root :to => 'products#index' end When running rake routes it outputs the following: edit_shop_product GET /shop/products/:id/edit(.:format) {:action=>"edit", :controller=>"shop/products"} But when I use the edit_shop_product_p...