Easy question: I need help writing an ActiveRecord find_all_by statement where I want to order things from newest created objects to oldest.
As a follow-up to this question: If I saved the results into a variable @records. How do I then ask for the next record in it? I want to do something like @current_record = @records.next
...
Hello, newbie here, first post.
I just spent like 4 hours trying to assign one category to a post (trying out a regular blog thing) via radio buttons, to no avail. The association is working fine, and ultimately I managed to get it working with a select menu, but for some reason it seems radio buttons are simply not meant for that.
I ...
I'm writing a small CMS as a Rails test project (also planning to use it for my personal website). I want SEO-friendly URLs so I have a test to verify that permalinks are automatically being created based on a page's title (e.g. About Us => about-us). I can't figure out why this test is failing, however. Here's the code (I'm using Rai...
I have a small rails app that is using acts_as_list to implement drag and drop via ajax.
The app has 3 main models: forms, sections, and questions. As it is designed, forms have many sections, and sections have many questions.
I want a user to be able to do 3 things:
reorder the sections in forms
reorder the questions in the secti...
I want to parse a random website, modify the content so that every word is a link (for a dictionary tooltip) and then display the website in an iframe.
I'm not looking for a complete solution, but for a hint or a possible strategy. The linking is my problem, parsing the website and displaying it in an iframe is quite simple. So basicall...
I am a novice linux user trying to come to terms with *nix development using Ruby on Rails. I am reading an excellent book titled "Simply Rails 2" [SitePoint:lenz] and haven't had any problem until I try to create a new Story object within the rails console and I get a "no driver for sqlite3 found" error:
$sudo ruby script/console
Load...
In the current app I'm building I've got a textarea where a user will enter a comma-delimited list of email addresses.
I'm currently splitting the list into an array and then saving one by one. But if, say, I have this input...
[email protected], test@example, [email protected]
... then [email protected] will be saved, but saving test@ex...
I'd like to create a before_filter method in my application controller like this...
def check_role(role_name)
unless logged_in_user.has_role? role_name
flash[:notice] = 'Access to that area requires additional privileges.'
redirect_to :back
end
end
However, it doesn't look as though before filters can take parameters.
Is ...
I have a situation where the header partial is called by the standard layout. (This is fairly common I assume) In the header is a search box - just like on stackoverlow. However, when the user is on the search page, I want to remove the search box from the header.
What I attempted to do was put a method in the ApplicationHelper.rb file...
Any tips on how to implement sorting and pagination on a resource in a Rails application and still keeping it RESTful?
How do I map the parameters for page number and sort field in a clean way? (I am currently using map.resources :x for every resource in my app)
Any other performace issues involved that I should know about? (eg. cachi...
I want to add a method to the Array class in a rails app. Where should I put this method?
EDIT to be clearer, obviously I put it in a file somewhere, but how do I tell the rails app about where to find it?
...
I need a quick solution to getting some decent layout working within the tabnav widget display area. I'm already using blueprint css for other aspects of the layout but I don't have enough CSS chops to figure out how to get blueprint containers to display within the tabnav's content area.
The tabnav's content area is <div class="main_...
I'm attempting to learn Ruby on Rails. I'm pretty confident with the basics and writing my own models, controllers and views, although I only know the basics.
Lately I've found that, when I start a new application, most of my models nicely fit into the REST philosophy, and I end up just writing most of the same scaffold-generated cod...
Rails has frameworks such as ActiveMerchant and Freemium (which uses ActiveMerchant) to simplify dealing with payment processing. What other frameworks are there for other programming languages such as PHP or Python?
...
Let's say I have four completely independent models (Movie, Book, Game, Album) that control the types of things I have in my media collection. With them I can CRUD and tag individual albums, movies etc.
But I need to keep track, and do some stuff that is common to, all of them. So I figured I need an Item model that would give me a tabl...
How can you set a cookie on a different Domain that is calling my site with a javascript call? It works in FF3, but not in IE6.
My server is called from a javascript tag on a seperate site and domain. The result returns javascript that populates their page with data (it's a widget). I am trying to set a cookie using domain=".mydomain....
I've been a Visual Studio user since 1997, and used VB 3.0 before that. My whole professional life has been spent inside the Microsoft development environments.
Now I would like to branch out into Ruby on Rails to try something different, and it doesn't have the kind of vendor support that C# does (for very obvious reasons).
For someon...
There's a rails recipe that illustrates how to do this in rails 2, but now that sexy rack is in, the solution seemed no longer relevant. How can this be handled in rails 2.3.2?
...
I have a many-to-many relationship like this:
class Event < ActiveRecord::Base
has_many :calendar_events
has_many :calendars, :through => :calendar_events
# ...
end
I want to make it so that when I call some_event.destroy Rails deletes the association records from the calendar_events table. Based on the API docs, I'm assuming yo...
I've launched a website today which makes heavy use of Starling and Workling to handle the background task queue.
Traffic has been heavy and although my server CPU/memory has not been under too much strain, the job queue is seriously backing up.
I am inexperienced with both Starling and Workling and urgently need to understand how I ca...