Rails: Modifying a Model Generated by Scaffolding
How do you modify a model you've generated using modeling? For example, the model myModel originally had columns a, b and c, but I now want to add column d. ...
How do you modify a model you've generated using modeling? For example, the model myModel originally had columns a, b and c, but I now want to add column d. ...
I've worked my way through a number of interesting routing problems - turning a request URL into a hash, etc., but just out of curiosity, is there a way to tell the routing system that you want anything that comes under a certain url subpath to be served literally - without going through a controller? For instance, if I have /home/me/...
In my current Ruby on Rails view we have many views and partials. So many in fact that it's not clear which view uses which partial (which itself may use other partials as well). The question is if there's a tool out there that generates a dependency graph of all views and partials (ideally generating a graph, but that's easy to do) or ...
I have a fairly intensive algorithm that must be run pretty often (many times per second) in my RoR application. Considering how slow Ruby is with this kind of stuff, I don't think it would be good to do the work in Ruby. You may be thinking I should add it to a work queue of some sort and have a C++ app work it down, but I need the res...
Given the following two (simplified) models: class Customer < ActiveRecord::Base # finder sql to include global users in the association has_many :users, :dependent => :destroy, :finder_sql => 'SELECT `u`.* FROM `users` `u` WHERE (`u`.`customer_id` = "#{id}" OR `u`.`customer_id` IS NULL)' validates_presence_of :name end clas...
This is using Rails 2.2.2 I have a model that uses the acts_as_flaggable plugin, and on the page I use to display an instance of the model, I list any flags that the model has. When I start my Rails dev server(mongrel) using the standard script/server command, load the page holding the following code, it loads fine: <% @object.flags.e...
Is it possible to invoke a method when the initial state is entered when using the AASM Gem? I'd like the spam_check method to get called when a comment is submitted, but it doesn't seem to work. class Comment < ActiveRecord::Base include AASM aasm_column :state aasm_initial_state :submitted aasm_state :submitted, :enter => :sp...
I'm looking for a Rails plugin that eases the development of a "friends" system or social networking system for the latest versions of Ruby on Rails. Before anyone says it...I know, I should probably create it myself, from scratch. And I am fully capable of this (I think). I'm just looking for a good plugin that can a.) make life a bit ...
I'm trying to write an ActiveRecord find query with no success. Please help! This feature of my project is kind of a blog with Digg-like features: each registered user can add a star to the blog post itself or any of its replies. So here are the relevant model classes: BlogPost (has_many Replies) Reply (belongs_to Blog Post) Starrin...
Hi, I'm new to Rails and I'm aware it has things such as unit-testing built in. But I'm interested in doing some more simple tests that are equivalent to your "printf" in C. So I'm testing a login page I've written and want to trace the code to see what each line like my find methods are returning. I try outputting with "puts" but I don'...
The button_to causes a line break before it in HTML. I have found a workaround which will work, but it's hardly ideal, because then the buttons are NOT real buttons. Is there any other way to avoid the line break before the form? Here's the resulting HTML <a href="/last_page">Back</a> | <form method="post" action="/next_page" class="b...
ActiveRecord query caching is enabled when a controller's action is invoked. I also know that you can do something like this to temporarily enable caching for a given Model for a given code block: User.cache do .... end But is there a way to enable query caching for other contexts (e.g. when a script is run under the rails envi...
How would you model the references and citations to publications (articles, books, chapters, etc...)? A publication can be an article, book or a chapter and it has many references to other publications and other publications refer to it (call these citations) I need to be able to list the relationships among the publications: The refer...
I'm currently working on a largish Ruby on Rails project. It's old enough and big enough that it's not clear if all views are actually in use. Is there any script/plugin out there that can generate a list of unused view files? ...
Hi there, I have a page that will list news articles. To cut down on the page's length, I only want to display a teaser (the first 200 words / 600 letters of the article) and then display a "more..." link, that, when clicked, will expand the rest of the article in a jQuery/Javascript way. Now, I've all that figured out and even found th...
Scenario: I load some data into a local MySQL database each day, about 2 million rows; I have to (have to - it's an audit/regulatory thing) move to a "properly" administered server, which currently looks to be Oracle 10g; The server is in a different country: a network round-trip current takes 60-70 ms; Input is a CSV file in a denorma...
How would you handle allowing users to add child objects to parents without requiring them to navigate to the parent? For example adding a journal article without having to navigate to the journal and issue first? The parent also may not exist yet. I'd prefer not to make data entry to onerous for users so making them find a journal or...
Which version control system should I use for a Rails app: Git or SVN? Here are some factors to consider: I'm the sole developer I'm familiar with SVN I've only used Git for a week, it seems pretty similar to SVN really. I want to put my repository on a remote location and connect to it via SSH or other protocol (which I already do wi...
There exists the multisite plugin (http://github.com/dasil003/rails-multisite/tree/master) that allows for multiple view folders based on different sites. It especially allows you to only overwrite certain views in a site and leave the others untouched (i.e. the other views don't exist twice). Does something like this exist for ActionMa...
If I type this big integer: puts 9997836544.class.to_s and compile with ruby 1.86, it reports expectedly: BigNum while JRuby (1.1.4 in Netbeans) reports surprisingly: Fixnum I thought Java had a BigInteger class to correspond to the BigNum class in Ruby. If so, I would have expected JRuby and ruby to produce the same output. ...