I am interacting with a time duration in a rails form, currently it is a text box and the format requires MM:SS
I have the validator:
validates_format_of :time, :with => /^[0-9]?[0-9]{1}[:][0-9]{2}$/, :allow_nil => true, :allow_blank => true, :message => 'format must be MM:SS'
though I want to store this in the database as an integer...
Hi, when trying to do a search box in a Rails project, search is based on input id numbers, I am using a text_field_tag with a observe_field. But the strange thing is that the the search box wouldn't trigger a event unless user pressed enter. I would expected that it would do incremental search, react when user input a new character (num...
I heard that HAML has a capture function that can do something like Ruby on Rails's render_to_string, but can't find info on it. Actually, in View, we can use aString = render :partial ... and render actually works the same as render_to_string (as on Rail 2.2.2). But is there also an HAML way of doing it by capture?
...
I have the following code in a layout:
Posted <%=time_ago_in_words post.created_at %> ago
<% if post.has_tag != nil %>
in the <%= post.get_first_tag.name %> category
<% end %>
And the following code in the post model which is inheriting form ActiveRecord::Base
def has_tag
!self.tags.empty?
end
def get_first_tag
self.tags[0]...
In the process of looking at my logs from Mongrel, I found some SQL statements that I wanted to optimize. While looking into these, I noticed that these entries sometimes have CACHE in front of them, e.g.:
CACHE (0.0ms) SELECT * FROM `customers` WHERE (`customers`.`id` = 35)
Given the execution time, I'm assuming Mongrel really is ...
I have a rails application running in a staging-environment, which is an accurate copy of the production. I would like to be able to send mails with ActionMailer, to test that it all works as it should, but to prevent any mistakes, I would very much like to be able to restrict the mailer from sending out to any addresses that are not on ...
To be specific, I'm trying to get ActionController::Routing::Routes.recognize_path to recognize a route that is not in routes.rb, for testing purposes.
Is it possible to somehow mock or dynamically add a route? I'm using Rspec with Mocha.
...
Hi,
I've recently installed culerity to use on top of cucumber. But when I run my cucumber specs, they turn red (they were all green before).
The errors I get have this form:
Celerity::Exception::NavigationException:
com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException:
500 Internal Server Error for
http://localhost:3...
Can anyone provide a link to a description or tutorial dealing with the setup of https and installint certs etc using the Ruby RACK webserver?
Thanks
...
Hi all,
I want to be able to use friendly_id in a catch all route to render the page that it fetches.
for example
http://localhost:3000/business would render controller "pages" action"show" with id "business"
without leaving the url above.
The aim of this is to avoid things like localhost:3000/pages/business and make shorter urls.
I ...
Here's what I'm doing:
offers = v.offers.sort { |a,b| a.expires <=> b.expires }
This data is loaded via ActiveResource (so each set of instance attributes is defined by the data it contains). However, a recent change in the incoming data has made the "expires" attribute optional. Is there a class definition change that will cause the ...
I recently replaced acts_as_taggable_on_steroids with acts_as_taggable_on in my application and I keep running into a problem where rails cannot find a class associated with the new plugin. I think this is because I'm using the desert plugin and have extended some of the classes that exist both in the acts_as_taggable_on and acts_as_tagg...
Hi, could I have a stylesheets directory in Rails' plugin directory?
I am trying to write plugin for a existing Rails webApp, but still not sure how to customize
the default CSS for my plugin?
...
My current Ruby on Rails project does testing via rcov (specifically, relevance rcov, and we have a pretty high standard (we fail the build if we have < 95% code coverage).
We use the following command to test this:
rcov_cmd = "rcov --rails --text-summary \
--include #{included_dirs} \
--exclude #{excluded_dirs}...
Hi, I have a situation where I have Products, Suppliers, ShoppingLists and Valuations.
A shopping_list consist of many valuations each with a product, an specific supplier and a price.
My models are as follows:
class Product < ActiveRecord::Base
has_many :valuations
has_many :shopping_lists, :through => :valuations
end
class Supp...
I have a number of tags for each post. (Very similar to SO). I want 20 random items, non-repeating.
I know that I could use Tags.all.rand (And repeat 10 times) however, this won't guarantee uniqueness.
And I know I could use a SQL Query but since my development environment use sqlite as the db and MySQL in production, ORDER by RAND w...
I've got a rails app with a functioning restful_authentication system but I need to add password reset (never got around to it before...). Also I'm going to be probably adding things like invitations and some features that don't require login. And to be honest I was never completely happen with the way that restful authentication invaded...
I'm building a rails app where login is optional. In other words, many of the same actions/views/controllers/pages will work logged in or logged out. You simply get more functionality if you are logged in (like the app remembers what you've done).
I'm currently using restful_authentication and role_requirement, and wondering which level...
I am using will_paginate for paginating my results. Most of my site is AJAXified. All the records in the view can be edited/deleted in place. These records are paginated. I would like to know if there is any way to reset the pagination on AJAX destroy.
For example, say i have 20 records, with 5 records shown per page. If the user delete...
In Rails how do I call a form from another model in any given layout? I have a login form I want to put in the header of every page. I created a partial with the following in it:
<% form_for(@user_session) do |f| %>
<p>
<%= f.label :username %><br />
<%= f.text_field :username, :class=>'' %>
</p>
<p>
<%= f.label :pa...