As a long-time Ruby and Rails user, it never struck me until today to really think about the get-and-redirect pattern in Rails. The typical example of this would be calling a create() action, and then redirecting the user to a show() action to display the newly-created item:
class JournalEntries
def index
@entries = JournalEntr...
I have a multi select box in a form. the elements in this select box is being added/removed from javascript using DOM (e.g. http://www.digimantra.com/tutorials/add-append-remove-value-in-select-html-element-using-javascript/).
I want to get all the elements in the select box inside controller when form submitted.
is there any easy way t...
Let's say I have:
object A, B, C each with corresponding models, views, and controllers
How would you load them all into one view (site index)? You could use a partial of each model's index, but then methods of that particular controller don't get called so you would have to add that view's methods. Any other suggestions? Thanks!
...
I have associated two models Businesses and Ratings. A business can be rated many times, and each rating stores an integer from 0 to 5.
I would like to create a "Hall of Fame" page, where I list the top 10 businesses, by sorting businesses based on average ratings (which would use the Ratings model) and limiting the results to 10.
I'm ...
I have a controller within a namespace and would like to cache it's Index. I am successfully caching pages that are not under a namespace, and successfully caching fragments as well.
When I visit http//.../house/kitchen it successfully creates /public/house/kitchen.html. However it never finds it, so it is always writing over the cache...
Hello,
I'm trying to figure out how to accomplish a rendering over an existing rendered partial. Some background stuff first:
I have a table that is rendered based on data from DB. Outside of my rendered partial, I have various select tags which allow the data to update from on the specific select tag selected. I have tried to do th...
What is the best way to update a datetime field in a form.
I have a form and need to update both the date and the time.
I need to update the date with a date_select and then update the time using a time_select
I only have 1 field in my database. Event:date
I need to save the date in one field and then update the same field but add ...
in my test mongrel server output for a page, 8 queries are listed but many more DB are counted:
Query1
Query2
...
Query8
Rendered Partial1
Rendered Partial2
..
Rendered Partial40
Completed in 4754ms (View: 308, DB: 2246) | 200 OK
how do I show all the queries that are running?
Also, is there documentation for what the View; count repr...
I'm starting to use vlad for new deployments and am wondering what's the best way to set it up so I can use the same tasks for my local development and remote production servers?
I thought about defining everything as remote tasks then having dev/prod methods which set the domain variable, then I can just call rake dev/prod vlad:do_some...
I'm looking to create a Rails application with three models. One model represents cars, another represents the colors cars can be painted, and a third represents an order for a car in some color. What's the best way to structure the relationship between these models?
...
Hi All,
I'm looking for a mechanism by which to facilitate user preferences. I also want to have a set of "master" prefs that are used if the currently logged in user doesn't have a specific pref set. I see several questions similar to this, but they seem to get into theory instead of simply proposing a quality solution.
Basically I'...
I want to my controller in my app to not just respond to the id of the object sent from it's route, but actually a sha1 hash, i've generated using Digest::SHA1.hexdigest.
So instead of:
/client/invoice/1
I want the url to be something like:
/client/invoice/0beec7b5ea3f0fdbc95d0
...
It seems that setting multiple instance variables in a controller's action (method) causes problems in the template, only the very first instance variable got passed to the template. Is there any way to pass multiple variables to the template? Thanks! And why, in Ruby's perspective, does the template get access to the instance variables ...
This is a problem I've come across for a couple different projects I'm working on.
Since the projects are still under stealth development, and the problem itself is of potentially broader interest and agnostic to them, I'm going to anonymize it - but FWIW, I work primarily with Ruby/Rails and MySQL.
Scenario
I want to have a system f...
I'm writing an extension for Spree and I want to remove an existing association.
Given the following code:
class Project < ActiveRecord::Base
has_one :status
...
end
How can I remove the call to has_one :status at runtime? I want to remove the association and associated methods.
...
I managed to get Ajax working in Rails, specifically using remote_form_for tag to add Todos from Index. However when I do add them, there is a bullet mark next to them.
Here's my post/index
<% form_remote_tag( :url =>
todos_path, :method => :create,
:update => "todo_list", :position =>
:top, :html => {:id => 'todo_form'})
do %>
...
Is there a plugin/gem to log/record the history of rails script/generate commands?
...
Hi,
In PHP, is there any way to make class method automatically call some other specified method before the current one? (I'm basically looking to simulate before_filter from Ruby on Rails.
For example, calling function b directly but getting the output 'hello you'.
function a()
{
echo 'hello';
}
function b()
{
echo 'you';
}
Any a...
I'm in the middle of trying to upgrade a rails project from rails 2.0.2 to rails 2.3.5
In doing so, I've noticed a change that is driving me nuts. It seems that now by default, any queries that are run by the application get logged to the webrick console (I'm working in Eclipse/Aptana). It used to be that webrick would only show request...
I have three tables: Project, Tasks, and Tags. When migrate the databases in development mode, everything works.
But when I run the rake db schema load command for production mode, it isn't migrating the "Tasks" table, hence the app doesn't work.
I looked at my production.log file, but there isn't anything there.
What am I missing he...