Ubuntu -> Apache -> Phusion Passenger -> Rails 2.3
The main part of my site reacts to your clicks. So, if you click on a link, it will send you on to the destination, and instantly regenerate your page.
But, if you hit the back button, you don't see the new page. Unfortunately, it's not showing up without a manual refresh; it appears ...
Hi All,
A common idiom that my camp uses in rails is as follows:
def right_things(all_things, value)
things = []
for thing in all_things
things << thing if thing.attribute == value
end
return things
end
how can I make this better/faster/stronger?
thx
-C
...
I'm building an online store to sell products like "Green Extra-large, T-shirts". I.e., the same shirt can have many sizes / colors, different combination can be sold out, different combination might have different prices, etc.
My question is how I should model these products in my Rails application (or really how to do it in any applic...
Hi,
I have two models, one called Notes and one called Comments. Comments can be associated to many other models so I use a polymorphic association. In the schema.rb it looks like this:
create_table "comments", :force => true do |t|
t.text "body"
t.integer "user_id"
t.integer "commentable_id"
t.integer "commentable_type"
t.dat...
What is the best way to write unit test for code which gets current time? For example some object might be created only at business days, other objects take into account current time when checking permissions to execute some actions, etc.
I guess that I should mock up the Date.today and and Time.now. Is this right approach?
Update: Bot...
I've a Slice 256 with 4 Rails 1.2.6 sites running pretty decently on Lighttpd + FastCGI (Ubuntu Server 8.04 LTS upgraded from 6.06 LTS); although it's such and old configuration, it's proven reliable enough for my smallish websites.
Now I'd like to upgrade some to Rails 2.x and I'm wondering if the same Slice 256 can take an Apache2 + P...
I have a stories text field and want to show the first few lines say the first 50 words of that field in a snapshot page.In ruby(on rails) How do i do that??
...
What is the best way to solve the problem? User inputs and edits string "tom had a dog". I'd like the model and database to store "tom" and "had a dog" as separate fields. I recall solving this problem when dealing with telephone number strings but can't quite recall how I did.
...
Hi, i installed restful_authentication and its working, the login page allows me to login but i have another controller called admin and want to embed a login view inside the admin controller. Actually the url to the login view is : localhost:3000/login (it worked and i needed so that users can log in). I need : localhost:3000/admin/logi...
This should be simple, but I can't seem to find an easy answer.
How can I pass param values from the current request into a redirect_to call? I have some form values I'd like to pass into the query string of a GET redirect
I'd like to do something like:
redirect_to @thing, :foo => params[:foo]
and get sent to:
http://things/4?[foo...
I try to be as RESTful as possible in building applications but one thing that I'm never sure about is how to create a wizard-type work flow, be RESTful and concise.
Take, for example, a multi-page sign-up process.
Option 1: I can create a controller for each step and call new or edit when user gets to that step (or back to it). I ...
I'm developing a marketplace website where tutors and students can find each other. I'm building an online payment system (much like elance or guru.com) where the tutor can get paid and we take a cut.
Couple questions:
What's the best way to block IP addresses from certain countries like Nigeria? (Note, I am using Ruby on Rails so a...
Migrations are undoubtedly better than just firing up phpMyAdmin and changing the schema willy-nilly (as I did during my php days), but after using them for awhile, I think they're fatally flawed.
Version control is a solved problem. The main function of migrations is to keep a history of changes to your database. But storing a differen...
I am developing an app that needs to send text messages, so I have carrier information stored in a database. I also need that information in an XML file for client side code to read. To make this happen, I am writing a script that reads the carrier information from the DB and creates an XML file in the config directory. I felt this sc...
In rails, I know it is best to do a find through scope
e.g in questions_controller
def index
@event = Event.find(params[event_id])
@question = @event.questions
end
but is it also good practice to then do the same in the show action
def show
@event = Event.find(params[:event_id])
@question = @event.questions.find(params[:id])...
Hello - hard question:
I have my login-partial in my application.html.erb-layout.
Now I want to validate it, if the user pushes the submit button and show error-messages for it, if e.g. the passwordfield is empty.
But how do I do that?
For getting the error messages, I must use
render :action => 'create'
But there I have to know, ...
I did something that caused this error when loading the home page:
undefined local variable or method
`javascript_include_tiny_mce_if_used'
I'm basically at the beginning of my project. I'm using Rails 2.3, and
worked through debug issues and got the home page and other user
profile loaded fine. I'm working on adding another use case u...
Hi, in my Rails app I want to have a similar profile section like Facebook where uploaded images are automatically thumbnailed and corner-rounded. I'm using the convert utility to downsize images into thumbnails, but is there an option to round their corners too? Thanks.
...
I want to create a thread object in environment.rb and use it in some other action of some controller.
How should I do it?
Thanks in advance.
...
I want to be able to "deep clone" 10 instances of an ActiveRecord model and all its associations into memory, work on them, update the in-memory objects and then, when I've finished, pick one to write back over the original in the database.
How do I deep clone (i.e. .clone but also cloning all associations right down to the bottom of t...