ruby-on-rails

Getting a loop when using link_to :back

I have this structure for the table course: Search page -> Result Page -> Edit Page -> Show page When i go from result page to a specific course edit page, i edit it, and end up on the show page, but when i hit back, i get a loop from show to edit, and back to show and so on. I want the edit page to back to the result page if it came ...

where can I find the code where rails connects to the database when booted

Can someone point me to the code where rails reads the database.yml file to connect to the database when booted. I am using Rails 2.3.3 thanks, ash ...

Trouble rendering a view inside a generic class

I'm trying to encapsulate the logic for generating my sitemap in a separate class so I can use Delayed::Job to generate it out of band: class ViewCacher include ActionController::UrlWriter def initialize @av = ActionView::Base.new(Rails::Configuration.new.view_path) @av.class_eval do include ApplicationHelper ...

How can I get FOUND_ROW()s from an active record object in rails?

When querying the database with: @robots = Robot.all(:condition => [:a => 'b'], :limit => 50, :offset => 0) What is the best way to get the total number of rows without the :limit? In raw MySQL you could do something like this: SELECT SQL_CALC_FOUND_ROWS * FROM robots WHERE a=b LIMIT 0, 50 SELECT FOUND_ROWS(); Is there an active r...

Problem with Railscast #197 - Nested Model Form Part 2

I'm trying to implement Ryan's Railscast #197 in a system with Questions, Answers, and (multiple choice) Options. http://railscasts.com/episodes/197-nested-model-form-part-2. I have successfully implemented the nesting among these forms/partials. The simpler 'check box' way to delete records works properly. The problem occurs when I tr...

Ruby on rails - how to retrieve connection strings

Hi Everyone, Are there any ways to retrieve the database connection string where my ruby is connected? what i would like to get is the: 1) Database name where the ruby is connected 2) The username of the SQL Server 3) Password of the SQL Server 4) Server name I want to store it in session variables. (I'am using MS SQL Server.) Pleas...

Two Tables Serving as one Model in Rails

Is is possible in rails to setup on model which is dependant on a join from two tables? This would mean that for the the model record to be found/updated/destroyed there would need to be both records in both database tables linked together in a join. The model would just be all the columns of both tables wrapped together which may then b...

Rails auto_complete "undefined method `auto_complete_for'" problem

rails -> 2.3.8 ruby -> 1.8.7 After auto_complete plugin installstion i still have "undefined method `auto_complete_for'" problem! Andrey-Bezruks-MacBook-Pro:eyeonasia.stage wizeflux$ ruby script/plugin install http://github.com/rails/auto_complete.git --force svn: '/Users/wizeflux/Projects/ionasia/eyeonasia.stage/vendor/plugins' is not...

How to save the view count of a question in memory?

My website is like stackoverflow, there are many questions. I want to record how many times a question has been visited. I have a column called "view_count" in the question table to save it. If a user visits a question many times, the view_count should be increased only 1. So I have to record which user has visited which question, and ...

New Rails + Passenger deployment half working...not sure why?

I'm in the final stages of going round trip through the entire Rails cycle: development -> test -> production (on an external server). I'm very close...but seeing some errors with the production version and don't know enough about Rails' "magic" to troubleshoot it yet... this works: www.mydomain.com/rails and returns my app's view but ...

Queue management in Rails

Hi, I am planning to have something like this for a website that is on Ruby on Rails. User comes and enters a bunch of names in a text field, and a queue gets created from all the names. From there the website keeps asking more details for each one from the queue until the queue finishes. Is there any queue management gem available in ...

Why Rails.cache is not thread safe?

I know Rails.cache is ActiveSupport::Cache::MemoryStore, and it is not thread safe. I don't understand, why rails use a thread-unsafe cache as its default? Why not use ActiveSupport::Cache::SynchronizedMemoryStore? In my opinion, in a web site, if a cache is not thread-safe, it almost useless, because the requests are not handled in ON...

Change table row using Rails Ajax

I've a simple page with link_to_remote Rails Ajax function and HTML table. I'd like to change row of the table when click that link. This is my html. <table border="1"> <tr> <td><div id="ajax_result_1">1</div></td> <div id="ajax_result_2"><td>2</td></div> </tr> <div id="ajax_result_3"> <tr> <td>...

How to install a forked gem on Engine Yard?

I want to use the LinkedIn gem But not the one that I get when I type sudo gem install linkedin I want a specific one that somehow has done patches to. It is a fork of the original which is: http://github.com/jbasdf/linkedin I have downloaded sources from the above link, and use "rake" command to build a gem locally. So everything i...

Rendering partial for table row with form_tag is getting crazy!

I have 23(column)x6(row) table and change the row with link_to_remote function. each tr tag has its own id attribute. change link call change action and change action changes the row using render function wit partial. _change.html.erb <td id="row_1">1</td> . . omitted . . <td id="row_23">23</td> link_to_remote function <%= link_to_...

file_store of rails' cache

I am using the :file_store as rails' default cache, to hold the view count of articles, but I'm not sure the what's the performance of a file cache. Will there be any problem when handling some requests at the same time, and each request uses this cache? ...

Rails Dreamhost Cron Job

I'm trying to get some cron jobs going through Dreamost using their panel. I'm also using rake to execute these jobs My rake files are located in app/lib/tasks/example.rake But I don't know what code to give the panel to execute them ...

How to start with Ruby on Rails on Mac OS X Snow Leopard?

Is there any good tutorial on how to get things installed and working on Mac OS X Snow Leopard? Also which tools do you use? TextMate? Or something else? I am trying my first steps with RoR after years of ASP.NET development on Windows platform but I am getting curious to learn other things as well to become a better developer. ...

NO METHOD ERROR in rails i am new new for rails

the extracted source is below Showing /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/templates/rescues/diagnostics.erb where line # raised: private method `gsub' called for #<NoMethodError: undefined method `closed?' for nil:NilClass> Extracted source (around line #): RAILS_ROOT: /home/sharath/Desktop/RORWorkspa...

How can I export a rails model to json schema?

I am looking to optimize how we build forms for some of our models and ideally I would like to build them from json-schema. Is there a gem or the like which would allow me to export a model definition to json-schema? Bonus: With validations. Bonus: While modelling association relationships. ...