ruby-on-rails

Best practices when including/using a "partial view"?

In modern web frameworks like Rails and symfony the concept of partial includes or partial views is well documented and recommended. What I am having trouble with lately is deciding how much design to include in the partial. It's kind of hard to explain but I want to know what others do when creating a partial and including it in a tem...

Should I use .erb or .rhtml files for a Rails app in which all Controller logic exists in Views?

I'm just starting to learn Rails. I created an empty Rails app. And instead of writing a Controller, I want to put all of my Controller logic in my Views instead of in separate Controller classes. To do this, should I use .erb files or .rhtml files and what's the difference? ...

How to configure Ruby on Rails with no database?

It would be convenient to use Ruby on Rails for a small website project that has no current need for a database. I know I could create an empty database in MySQL and go from there, but does anyone know a better way to run Rails without a database? Thanks, Rob ...

Is it possible to avoid following the MVC pattern while using Rails?

Some of the responses to a question I asked today earlier today have caused me to question my assumption that it should be possible to use Rails in a non-MVC manner as opposed to simply using a microframework like Sinatra for barebones non-MVC-type apps. Has anyone used Rails in a non-MVC manner without it causing major problems or coul...

What are PHP's advantages over Ruby on Rails and Django?

PHP was the undisputed king of easy webapp development, until Ruby on Rails, Django, and other dynamic programming frameworks appeared. What are, in your opinion, PHP's strengths against the newcomers? ...

How does Phusion Passenger reuse threads and processes?

I am setting up an Apache2 webserver running multiple Ruby on Rails web applications with Phusion Passenger. I know that Passenger spawns Ruby processes for handling requests. I have the following questions: If more than one request has to be handled at the same time, will Passenger spawn multiple processes or multiple (Ruby) threads? ...

Build vs New problem

Has anyone run into this problem? I have a collection of comments that I loop through in the view as normal: <% for comment in @post.comments %> <%= comment.body %> <% end %> But I also have a form to add a comment, but it seems that if I use @post.comments.build instead of Comment.new in the controller, that it created a blank ins...

How do i add a new action to an already created controller?

I am using rails and i need to know how i add a new action to my controller, im a beginner in rails so i dont really know if i just type "def action" in the controller.rb or is their more too it then that? Thanks. ...

multiple joins using activerecord in rails

I'm building a small twitter style microblogging service where users can follow other users and get a feed of their messages I have the following models: class Follow < ActiveRecord::Base belongs_to :follower, :class_name => "User" belongs_to :followee, :class_name => "User" end class User < ActiveRecord::Base has_many :follows,...

Is it possible to use a "front controller" in Rails?

In Spring MVC a Dispatcher servlet is used as a "front controller" to handle all of the application requests and route them appropriately. Is it possible to use such an approach in Rails or is it required to write a separate controller for each type of action without having a "traffic cop" (front controller) directing the flow? ...

What's the best way to keep up to date on the latest news in the Rails world?

When I read some of the answers on here I notice that some people are aware of upcoming changes to Rails syntax and I'm not sure how they find out about them. What's a good source of the latest information on syntax changes or updates to Rails? ...

Is it correct that there are particular times when you may need to restart Webrick to see your changes?

I heard Kevin Skoglund (lynda.com) say that it is good practice to get in the habit of restarting Webrick frequently during development. Although generally you do not need to restart Webrick to see your changes, he implied that there are particular times when this may be needed? Does anyone know what those circumstances might be? This ma...

how does Stack Overflow show interactive character limits?

How does Stack Overflow show interactive character limits? Like when editing comments, it shows you how many characters you have left, as well as warning if it is too few. I'd like that exact functionality in my Ruby on Rails... But not sure how to do it? ...

Thinking Sphinx - Delta indexing doesn't work

In my app, I need every new record to be added to the index instantly (not after rake ts:index). If I understand it correctly delta indexing is what I'm looking for. So, I added delta column to every table I'm indexing with Sphinx, set the default value to false and added set_property :delta => true to every define_index block; then ran ...

While processing an email reply how can I ignore any email client specifics & the history?

I have a rails application which processes incoming emails via IMAP. Currently a method is used that searches the parts of a TMail object for a given content_type: def self.search_parts_for_content_type(parts, content_type = 'text/html') parts.each do |part| if part.content_type == content_type return part.body e...

Rails app randomly crashes with error "Premature end of script headers"

I am hosting a Ruby on Rails 2.0.2 application on DreamHost. It is on an Apache 2 server, running on top of Phusion Passenger. The application often returns a 500 error "Rails application failed to start properly", but at random times. It appears to happen when the application is under higher load, though I can't confirm this. It only ...

Rails - Creating a select tag from a object hash

I need to create a select box from the values available in a Hash. For instance, I have a 'thing' and the 'thing' has a variety of status fields: 1 => 'State A' 2 => 'State B' available via a method on thing. How can I build a select tag from this? ...

How to create a sortable interface with 'acts as nested set' in RubyOnRails

I've been implementing some nice interactive interfaces that can sort lists in my m rails app for models that use acts_as_list. I have a sort function that gets called and sets the position for each record afterr each drag and drop using the sortable_element script.aculo.us function. This is an example of the controller action that han...

How to implement a profanity filter in RoR?

I am developing a social web application with RoR. I realized that it's probably a good idea to prevent users from inserting rude or profane language into comments or posts. Do you know any solution or plug-in that help me prevent something like this? ...

Rails ActiveRecord - is there a way to perform operations on tables without an id?

I have a table with one row and two columns- int 'version', datetime 'updated' Is there a Rails ActiveRecord way to get and set the data in these columns? There is no id column. I'm using this table to track versions of queries of other tables. After each query of another table the version column is incremented and the updated colum...