I have a rails form that that displays a date in a text_field:
<%= form.text_field :check_in_date %>
The date is rendered at yyyy-mm-dd
I'm trying to figure out how to have it display as mm-dd-yyyy
I tried adding this config but it didn't work.
ActiveSupport::CoreExtensions::Date::Conversions::DATE_FORMATS.merge!(
:default => '...
Hi,
Can I use helper methods in rake?
Thanks.
Sam
...
I installed Snow Leopard and things have been going great, after a few re-installs. But now when I go to run cucumber, I get the error below, and I can't find anything conclusive through Google searches. Has anyone run into this, or maybe have some troubleshooting steps to try?
$ cucumber features
dyld: NSLinkModule() error
dyld: Libr...
Hi,
I was wondering how to add custom configuration variables to a rails application and how to access them in the controller, for e.g I wanna be able to define an upload_directory in the configuration files say development.rb and be able to access it in one of my controllers.
Secondly I was planning to have S3 support for uploads in m...
I am working on an an application that allows a user to search for a particular book on Amazon using a given search criterion (e.g. title, keyword, author.) I am currently attempting to store these search results to a MySQL database, but am struggling with the concept of relationships.
It seems natural that I would structure the models ...
Can I create a Rails model where the ID auto-increments from 0, not 1? How? Are there any gotchas? I checked here, and it seems I can't:
http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/SchemaStatements.html#M001911
If, as it seems, I cannot, is there reason why I can't or shouldn't just manually assign an ID of 0 to ...
I want to create a set of values in Ruby which I can store and retrieve in a MySQL databse under Rails.
In Delphi I would use:
//Create an enumeration with four possible values
type TColour = (clRed, clBue, clBlack, clWhite);
//Create a set which can hold values from the above enumeration
TColours = set of TColours;
//Create a var...
I have to create a database schema with Rails migrations.
I have lots of columns which contain quantities (kg) and prices (currency).
Currently I use this:
t.column :quantity, :decimal, :precision => 6, :scale => 3
t.column :value, :decimal, :precision => 6, :scale => 2
At the generator call I use quantity:decimal to identify my...
I'm new to Ruby on Rails (RoR). I created a new method on my controller. I want to call the new method from a view.
On my view, I have this code:
<%= link_to "MyMethod", :method=>:MyMethod %>
When I click on the link, the URL changes to http://localhost:3000/seats?method=MyMethod, and the page reloads on the browser and from the l...
While learning Rails I've created an application with a Domains controller nested below a Customers controller. I'm using Rails 2.3.4 and it's been a learning experience. I managed to get the below routing set up:
customer_domains GET /customers/:customer_id/domains(.:format) {:controller=>"domains", :action=>"index"}
...
Does anybody have any code handy that center truncates a string in Ruby on Rails?
Something like this:
Ex: "Hello World, how are you?" => "Hel...you?"
...
I have an image that belongs_to a user and to a binary (physical file attributes are stored in a separate model). In the old days (read: yesterday), I set the user_id value manually:
@image = Image.new( params[:image] )
@image.user_id = current_user
A friend recently clued me in to the fact that I should use associations instead, so m...
I'm trying to set up a Rails Template that would allow for comprehensive set-up of a specific Rails app. Using Pratik Naik's overview (http://m.onkey.org/2008/12/4/rails-templates), I was able to set up a couple of scaffolds and models, with a line that looks something like this ...
generate("scaffold", "post", "title:string", "body:str...
I am trying to modify a database Migration in a Ruby on Rails application. I am using MySQL as my database and would like to add foreign keys to the table that is being created. I am using the following code and while the specifications for creating null values on appropriate columns is being followed no foreign key constraints are being...
This is my code. I have a problem with spaces. I can not get the proper generation
- if @lastday.nil? && @lastday != item.created_at.strftime("%d %b %Y")
.daily-entry
%h1.date
=h item.created_at.strftime("%d")
%span
=h item.created_at.strftime("%b, %Y")
-else
.entry
%h1
= link_to item.title, "/i...
I have an existing Rails web application which I would like to integrate with Facebook, so that when the user takes actions in my application news items containing external links are later posted to the users wall / feed by a daemon which summarises the latest activity. I don't need single signon etc. at present, just the ability to send...
Hi!
How do you enforce DRY when you have shared code amongst rjs files? I'm trying to avoid the duplicated code in this example:
thanks!
...
I intend to store in a database a minimal amount of information pertaining to a book (title, isbn). However, on display I'd like to display additional attributes (pages, author, cover image) not stored in the database. I plan on getting this information from the Amazon Web Services (AWS) using Ruby/AWS. I am very new to Ruby on Rails and...
When someone visits my train schedule site, he enters a "from station", a "to station", and then submits the form to get the schedule.
I want the site to remember the user's last choice of from / to station when he next visits the site. Here's my current strategy:
In my index action (the action corresponding to the root URL):
def inde...
I need to use this in my rails program so I can get the image contents and then base64 it. I know how to base64 it but I just don't know how I would get the image. Anyone know how?
...