Rails has been good with automatically inserting correctly formatted datetimes in MySql without the need for me to give it much thought.
However, for doing a validation, I need to check if a stored mysql datetime value (ie 2008-07-02 18:00:00) is greater than or less than "now". I can call DateTime.now or Time.now but how can I convert...
Hi,
I'm trying to test a JS confirmation dialog with Cucumber on Rails. I have a window.onbeforeunload event handler that will prompt you with a confirmation dialog if you try to navigate away from the page but I have no idea how to test it, anyone have an idea on how this can be done?
...
With HoboFields, I can declare fields for my model in its own file, like this:
class User < ActiveRecord::Base
fields do
login :string
persistence_token :string
end
end
I'd like to know if there's equivalent syntax for the add_index command I can use in vanilla Rails migrations.
...
before the moans and groans, my client is using Godaddy to host his rails app. I have managed to get the app working for him, but Godaddy uses a sym link to point to the app which appends the root of the website ex.
www.yoursite.com/myrailsapp
I have tried putting this in the environment.rb
Basically all the links is suppose to work ...
I have a class instance variable on one of my AR classes. I set its value at boot with an initializer and, after that, never touch it again except to read from it. In development mode, this value disappears after the first request to the web server. However, when running tests, using the console or running the production server this d...
I'm pretty much just looking for the code they used that is very similar this this WYSIWYG when adding a comment. I want them to be able to hit return and it automatically throws in a <br /> tag. I know very simple way to get it to work in a text area if they know the HTML tags, but almost no users will. So I just want a few buttons li...
I'm playing with rewriting part of a web application in Rails + Ext. However, I'm having trouble getting an associated models' name to display in the grid view.
I've been able to successfully convert several models and arrange the views nicely using tabs and Ext's layout helpers.
However, I'm in the middle of setting up an association ...
How do you check what the datatype is for something that was retrieved from the database?
For example, if I have some instantiation of a model @model with a database field "title", I want to be able to code something like @model.title.type and have it return "String". Does Rails have any built-in functionality for this?
...
I'm not getting REST with Ruby on Rails, and I'm hoping someone here can set me straight.
Imagine that I'm building a site that keeps track of Widgets and the Users that own those Widgets. So I'd have a UsersController and a WidgetsController, and I could get a list of Widgets or Users with the index actions:
GET /users
GET /widgets
...
Hi All,
I'm looking to use "in_place_editor_field" on an "Index" page of items. Basically I want to mimic spreadsheet functionality for pre-existing line items in order to edit their attributes. However, none of the "in_place_editor" examples I've seen provide any useful real-world application of this nature.
Also, a lot of the exi...
Hi all,
I'm trying to set the expire headers for Rails' auto-versioned resources, like whatever.css?1234567890 . (I don't want to set the expire headers for unversioned resources.) The only method I could find online involved two steps: 1) rewrite all urls that end in 10 digits to load from /public/add_expires_header instead of from /...
Hello, I need some help with virtual attributes. This code works fine but how do I use it inside a plugin. The goal is to add this methods to all classes that uses the plugin.
class Article < ActiveRecord::Base
attr_accessor :title, :permalink
def title
if @title
@title
elsif self.page
self.page.title
else...
hi all,
i have two identical collection_selects on one page (one message belonging to 2 groups)
<%=
collection_select(:message,:group_ids, Group.find(:all),:id, :title, {}, {:name=>'message[group_ids][]'} )
%>
<%=
collection_select(:message,:group_ids, Group.find(:all),:id, :title, {}, {:name=>'message[group_ids][]'} )
%>
is it ...
I'm setting up AR_mailer to send mail. All works from a sending point of view, but when the mail is actually created I receive this error:
A LoadError occurred in users#create:
Expected /usr/lib/ruby/gems/1.8/gems/adzap-ar_mailer-2.1.5/lib/action_mailer/ar_mailer.rb to define ActionMailer::ARMailer
[RAILS_ROOT]/vendor/rails/activesup...
Is it possible to measure coverage using selenium-driven features?
...
I want to be able to change the default mapping of actions with RESTful url and type of request.
For example,
After adding map.resources :fruits in the routes, by default, sending a GET request to /fruits/:id calls show action in fruits controller. However, I would like to call a custom action, say display, in the fruits controller in...
How to properly extract a time only from the datetime object (post.created_at, to be precise) with/without the influence of TimeZone? How to extract the day, month, year? How to extract the day/month/year via a custom pattern (is it possible)?
...
How to disable the startup animation in OFC2? Since I started using the dz build, the on-show animation is on by default, which sucks quite a lot.
Neither of these work:
graph.animate=false
graph.on_show=false
Also, dz's build implements the tooltip hover support poorly - the tooltip continues to hover even when the cursor is on ano...
I can think of a million not-so-automatic ways to render a model in Rails, but I'm wondering if there's some built-in way to do it. I'd like to be able to this
<%=@thing -%>
obviously with partials you can do it (I mean, calling render :partial), but I'm wondering if there's some standard way to associate views with models.
[Thanks i...
I've noticed that the Rails log correctly displays the time taken to execute an action in the logs, and that the View: part of that is also rendered correctly. However, the DB: value is always zero:
Aug 11 13:00:22 [2326] INFO: Completed in 2072ms (View: 94, DB: 0) | 200 OK
In fact, all my DB timings are being logged as zero. I'm lo...