Displaying 20 results from an estimated 1000 matches similar to: "Spaces in Ruby on Rails and how to avoid them!"
2006 Jan 19
4
validates_presence_of
I am just going through the book and I come across a problem with the
code in the app/models:
validates_format_of :image_url,
:with => %r{^http:.+\.(gif|jpg|png)$}i,
:message => "must be a URL for a GIF, JPG, or PNG image"
It seems to moan when it''s empty even though I removed :image_url from
validates_presence_of. How should I make it optional?
2006 Jul 05
2
Serialized object behaves weird
Hi!
I got a class named EinsatzFilter which I serialized to session. Before
saving to session it works afterwards I keep getting the message:
"undefined method `to_s'' for #<Person:0x38c6ab8>". "Person" is a from
ActiveRecord::Base inherited class.
Code:
class EinsatzFilter
include ApplicationHelper
attr_reader :personen, :monat, :projekte, :kunde
2006 Feb 19
3
Rails urls & the AWD book
Greetings!
I''m having a hard time understanding the way Rails handles urls. I''m specifically having real trouble with the image_urls in the Depot app in the Agile Web Development book.
If I enter "\image\file.png" in the Add Product page, the image is displayed in the other views and Properties shows http://localhost:3000/images/file.png
If I leave off the leading
2005 Dec 29
4
Images in Agile Web Development with Rails
Hi,
I am working through Agile Web Development with Rails and I am at pg 69
second last paragraph says "put some images in the public/images
directory......" how do you code the link that is stored in the data base I
have tried http:public/images/name .jpg with no avail I have tried the fully
qualified address http://home/../../../../name.jpg also with no luck. How
should I code this?
2006 Dec 04
3
uninitialized constant Product
I am actually following the instructions/code snippets from "Agile Web
Development with Rails" and got as far as page 73 where I did ruby
script/generate controller Store index, then edited
store_controller.rb to
class StoreController < ApplicationController
def index
@products = Product.salable_items
end
end
and product.rb to:
def self.salable_items
find(:all,
2006 Jul 27
9
Introspecting validates_presence_of
Hello people,
I''d like to detect whether an attribute of a model has
vaildates_presence_of applied to it so I can automatically apply a
mandatory (*) to the field...it doesn''t look easy...any ideas?
Cheers,
--
Dan Webb
http://www.danwebb.net
2006 Jun 06
15
error working through Agile !!!
Hi everyone,
I''m working my way thru the ''Depot'' project from Agile Web Development
with Rails.
I got to the bit where I type:
ruby script/generate scaffold Product admin
And I get the following error:
error Before updating scaffolding from new DB schema, try creating a
table for your model (Product) ( on the last line ! )
Now I have followed everything as
2005 Dec 23
5
Can''t get data from products into @order
I went throught the "agile web developemnt with rails" and Now I''m
trying to ''enhance'' the code with some extra options. When I go to
admin/shipping I want to include some data from the products table in
with the order info listed. I can''t seem to get this to work. in my
partial form I''m trying to add this:
<td
2006 Jan 17
5
file_column mangling URL
Hey,
I''ve gotten file_column to upload a file, drop it in the dynamic
directory, but I can''t display the image, the directories repeat
themselves:
My model:
class Person < ActiveRecord::Base
file_column :image_url
In my view:
<%= image_tag url_for_file_column(''person'', ''image_url'') %>
HTML generated is this:
<img
2006 Aug 07
4
Unit testing diffculty
ok, let me show you my "products" fixtures file:
ram:
id: 1
title: RAM
description: ECC RAM Registered, 512MB
image_url: images/test.jpg
price: 29.95
date_available: 2005-01-25 00:00:00
busted_arsehole:
id: 2
title: Busted Arsehole
description: I have an arsehole, it is-e busted
image_url: images/test.jpg
price: 999.95
2008 Jun 07
3
DRY validates_format_of?
In a model I have following validates_format_of. Is there an easy way to
DRY this up? It seems to be rather repetitive.
validates_format_of :expiration_date, :with =>
/^[0-9]{4}[-][0-9]{2}[-][0-9]{2}$/
validates_format_of :activation_date, :with =>
/^[0-9]{4}[-][0-9]{2}[-][0-9]{2}$/
validates_format_of :some_other_date, :with =>
2006 Aug 09
8
AJAX image manipulation
I have this code in a controller that returns images to my browser...with
ROR.
def index
@products = Product.find_all_ pictures
end
....this is the .rhtml..
<% for photo in @pic -%>
<div class="entry">
<img src="<%= photo.image_url %>"/>
<h3><%= h(photo.title) %></h3>
<%= photo.description %>
2006 Mar 03
5
avoiding nil object error?
I''m a total Rails newbie and i''ve been struggling for hours today
with one (prolly very silly) problem:
I have a table portfolios that has many images:
class Portfolio < ActiveRecord::Base
has_many :images
end
class Image < ActiveRecord::Base
belongs_to :portfolios
end
In the controller i define a list of active portfolios:
@active_portfolios =
2006 Apr 18
10
Validates_ip_of
Hello all
After being told of a funky date validator I will ask again for another
validator :) Does anyone know of a plugin that validates that a field is
the correct syntax for an IP Address?
Thanks
Jeff
--
Posted via http://www.ruby-forum.com/.
2006 Jan 30
1
how to get column_for_attribute?
Hi all,
In the code below I don''t understand:
1. Why I have to prepend overriden method content_columns with "self."
to get it working?
2. Why column_for_attribute method is not working (no such method?) even
if SomeTable is subclass of ActiveRecord::Base which have public
column_for_attribute method?
> class SomeTable < ActiveRecord::Base
>
> def
2005 Nov 28
4
validates_format_of nil
I''ve noticed that validates_format_of will return invalid if the field
is nil.
Question 1) How should we declare a validation that will validate it
with a regex if it is set, but, if the field is not set, just move on
Question 2) Why is it done this way? The other validators are only
invoked if the field is set . If you want to declare the field
mandatory, you add a
2006 Apr 27
2
"for column in..." not picking up _id columns
My code executes fully:
<% for column in ModelName.content_columns %>
<th><%= column.human_name %></th>
<% end %>
but it does not pick up any columns in my model''s table that end in
"_id".
Is this by design?
Is there a helper method that will reference the related tables? Or
will I need to code the column titles and detail records by
2006 Apr 05
4
validates_format_of ?
Hi all,
I''ve got a form which accepts a "price" field and I''m attempting to
validate it and allow some flexibility in the way the user enters it.
It''s a numeric field but I want the user to be able to enter dollar
signs and commas naturally in the data entry.
I''m trying to understand how to use validates_format_of, and I''m not
sure what
2012 Aug 14
3
validates_format_of :message not working, validates_length_of :message is working
I''m using validates_format_of and the validation I want to do works, but I
can''t get an error message to be displayed if the data is invalid:
validates_format_of :mobile, :with => /\A[\+0-9]+\Z/, :message => " - Wrong"
I have another validation some where else that does display the error
message: " - Name is too long"
validates_length_of :name,
2010 Dec 06
10
testing chapter: agile web dev withrails
I am working my way through Agile web development with rails and I''m in
the testing chapter.
when I run the following test(or any other test)
I''m new and not sure where to start looking.
require ''test_helper''
class ProductTest < ActiveSupport::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end
I