In the mailbox section of my Rails app, I simply display the timestamps of each message as follows:
<%= message.created_at.utc %>
But I want to change it so that if the message's date is different to today, then display the date, otherwise just display the time (e.g. like Gmail).
...
I'm just learning how to program in Ruby on Rails, and I'm really impressed by how much work the Ruby on Rails framework does for you. I have the following two classes:
Object
--------
object_id
description
ObjectGroup
--------
group_id
description
The idea is that I have some objects, and I'd like for the users to be able to define...
How do I send a cookie in a functional test? How do I test to be sure that the cookie is cleared?
I've had great success using TDD to build the models for a Rails application, but have hit a snag with regard to controller testing: I can set cookie values once in a test and read them, but I can't clear them. That is:
test "clears cookie...
I'd like to apply the action_mailer patch mentioned in this thread but I have never applied a patch before and I'm not sure how these work:
https://rails.lighthouseapp.com/projects/8994/tickets/2263
My action mailer gem is here: /opt/ruby-enterprise-1.8.6-20090421/lib/ruby/gems/1.8/gems/actionmailer-2.3.2
I assume I need to go to that ...
Hi People,
I am trying to get into web development, specially interested building the front-end, UI part of websites while learning JavaScript maybe with AJAX technology. (I have a UI, HCI background.)
However, I have absolutely no previous knowledge about server-end web development either. To my understanding, frameworks like Django s...
The Rails console doesn't seem to like multiple ruby statements on the same line separated by a semicolon. Whenever I do this, the next line starts with ?> and I find that only the first statement was executed. Do you have to put each statement on a separate line?
>> user = User.new
user = User.new
=> #<User id: nil, username: "", hash...
I am facing an issue where my Rails application is set to cache classes when run in the staging or production environment. While load_paths only contains 'app/models', it appears that the initialization steps recursively caches everything in 'app/models'.
# Eager load application classes
def load_application_classes
if configur...
With a Ruby module, you can cluster together a bunch of methods that you might use in one place and then include them into a class so it's as if you had written them in that class.
What kinds of practical uses are there for Ruby modules in a rails app?
I would appreciate if someone could mention an example of where they've actually u...
Hi,
I need to format a decimal like this:
00.33
11.24
05.22
The problem is that when I retrieve 00.33 it outputs as 0.33.
I have tried everything and can't get it to work correctly. I could do MySQL's Zerofill but I'm really trying to avoid that.
Any suggestions?
Thanks!
...
I have this bit of code and I get an empty object.
@results = PollRoles.find(
:all,
:select => 'option_id, count(*) count',
:group => 'option_id',
:conditions => ["poll_id = ?", @poll.id])
Is this the correct way of writing the query? I want a collection of records that have an option id and the number of...
Is there any way possible to get the child paths given a path?
I mean given the following routes:
map.resources :users do |user|
user.resources :articles
...
end
If I give path = "users/1", is there any way to get the routes
users/1/edit, users/1/articles, users/1/articles/new ?
Thanks in advance.
-Satynos
...
I am developing an application that is supposed to have games, when one clicks on the game it will go to game.prestart with instructions and other stuff. There I wrote:
link_to "Play", :controller => "games", :action => "wait"
wait will wait for other players and later redirect to the "play" action
Two questions here:
1.- This is n...
This is something I've been stuck on for a while now, and I have to apologize in advance for going into so much detail for such a simple problem. I just want to make it clear what I'm trying to do here.
Scenario
So, there's a model Foo, each Foo can either be red, green, or blue. Having URLs like /reds to list all red objects, and /red...
Hey all, I am completely lost on this one.
I found a code snippet online to help validate fields via ajax as the user types into them. So I'm trying to write a spec against part of it and I just can't get it to pass.
Here's the code
def validate
field = params[:field]
user = User.new(field => params[:value])
output = ""
user...
One of my Rails applications is going to depend on a secret key in memory, so all of its functions will only be available once administrator goes to a certain page and uploads the valid key.
The problem is that this key needs to be stored securely, so no other processes on the same machine should be able to access it (so memcached and ...
Hi,
I'm writing a facebook style messaging system for a Rails App and I'm having trouble selecting the Messages for the inbox (with will_paginate).
The messages are organized in threads, in the inbox the most recent message of a thread will appear with a link to it's thread. The thread is organized via a parent_id 1-n relationship with...
For the caching purpose I can't have url like /users/2/index?month=2009-02 . The problem with this approach is that if I do page caching then same page is returned even for /users/2/index?month=2009-03 .
To solve the caching issue I would like to have url like /users/2/events/2009-02.html . I have defined users to be a restful resource....
I'm attempting to create a hierarchal menu system in rails.
My menu model is in a tree data structure, and I need to pass the parent information to the new action. The best way i found to do this was to pass the parent's id as a querystring. This works, unless validation blocks creation. The problem is that after the new view is rendere...
I'm working a project that has recurring, weekly events. Thus, I use several DateTime fields in a nontraditional way. What I'm working on is a FormBuilder that creates a field that outputs a select for a weekday, and a select for time. I'm using a twelve-hour plugin I found online, so that works:
class ActionView::Helpers::FormBuilder
...
I'm using the restful_authentication plugin for my login page. The problem is that after I log in as a user, I never get logged out until I click on log out. How do I set a session timeout of 15 minutes? For example, after 15 minutes if I go to any page, I should be redirected to the login page.
...