[Rails] Re: Ensuring a password is Alpha-Numeric

2009-09-20 Thread Felix Schäfer


Am 20.09.2009 um 05:46 schrieb Wang Pengcheng:

 First , please use the white list not the black list in the regex.
 Second, please validate the length of the input data.

 /^[\d\w]+$/i

As a side note, and if you insist on being pedantic, I'd suggest using  
\A and \Z to delimit the beginning and the end of the whole string in  
the regex, as opposed to ^ and $ only matching the beginning and the  
end of a line in ruby, who knows, maybe one your users will try to use  
a password with a newline in it ;-)

Felix

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] coordinates for geokit

2009-09-20 Thread bingo bob

i'm trying geokit and loving it, but i'm seeing really odd stuff on
distances, I'm wondering about the coordinates i've got in my DB. I
don't think they're standard format, they look like this.

east 6'41.6 north 45'24.8

Can anyone advise please ?
-- 
Posted via http://www.ruby-forum.com/.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: coordinates for geokit

2009-09-20 Thread bingo bob


Someone said i can convert these with a regex ? that right ?

Maybe on the fly ?
-- 
Posted via http://www.ruby-forum.com/.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] is there a ruby on rails framework/app that would be a good starting point for these requirements???

2009-09-20 Thread Greg Hauptmann

Hi,

Just wondering whether there is an existing open source Ruby on Rails
app that would be a good starting point for doing this:

* want a backend web application/service that has an API to allow a
desktop client application to programmatically upload complete web
pages (HTML  images that the HTML links to) to be hosted
* the web application API would have to support (a) create account for
new user, (b) upload / modify / delete web pages for specified user
* part of creating the account for user would be to set them up with a
username/password, as the content needs to be private (user will need
username/password to access)
* so each of the accounts (setup with a user password) are all
separate with no linkages - it's just a service that will allow
multiple users to have their own HTML/images hosted, and the point
being that they won't manually set this up themselves, but rather the
clientside application will have the smarts to do this, therefore
requires the back-end web application/service to provide the API

Any existing open source apps sound like they might fit these
requirements, RoR blog app, or RoR Wiki app or something?  (but it
needs the programmatic APIs)

I guess the fallback for me would be to develop a website from the
ground up to do this (e.g. Ruby on Rails), but it would be nice to
have something as a starting point.


Thanks

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Sample Authlogic + Subdomain_fu application

2009-09-20 Thread xponrails

Hi all.

I've just created a template application that solves my problem:

http://github.com/devinterface/authlogic_subdomain_fu_startup_app



Skeleton Behaviour

This template sets up a working application with support for
authentication and subdomain.
Application workflow:

* Guest access a public section of the site (http://localhost:
3000)
* Guest chooses to register new account (http://localhost:3000/
account/new), including itself as user, and becomes account’s owner
* Accounts owner goes to his account (subdomain) url (http://
useraccount.localhost:3000/login) and logs into his account
* Accounts owner can add more users to it’s account (http://
useraccount.localhost:3000/users/new)
* Each created user can log into the account they belong

Skeleton features:

Here’s a list of what this template sets up:

Rails

* Authlogic
* Subdomain_fu

Javascript

* jQuery as javascript framework instead of prototype

CSS

* Blueprint as css framework

Testing

* BDD testing support using RSpec, Cucumber, and FactoryGirl

Other

Some other useful gems/plugins such as:

* Hpricot
* RedCloth
* Will Paginate
* SearchLogic
* Exception Notifier
* Inaction Mailer


Fell free to use/clone the template.

Cheers, Stefano


http://xponrails.net
http://rockmyevents.com


On Sep 14, 9:50 pm, Rails List rails-mailing-l...@andreas-s.net
wrote:
 xponrails wrote:
  Hi all.

  I'm going to start a new application usingAuthlogicwithsubdomain
  support (subdomain_fu) and I wonder if someone has just created a
  sample application to use as starting skeleton (that can be cloned/
  forked on github for example).

  Cheers, Stefano

 trywww.craigslistcloned.com
 --
 Posted viahttp://www.ruby-forum.com/.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Really stuck on nested resources

2009-09-20 Thread Colin Law

2009/9/20 mlittle mdlit...@gmail.com:

 Maybe I'm just going about my application in the wrong way. I'm new
 with rails and I'm trying to make sure that Child and Dog can only be
 viewed my the person who creates them. That's how I ended up with
 resources 3 deep. My resources are actually called User, Child and
 Parent. User is also current_user (I use restful_authentication) and
 all the resources are created by the current_user. My routes are basic
 but are 3 resources deep: User  Child  Parent. So, I reference each
 in my controllers by current_user.child and when I started trying to
 access current_user.child.parent, things started to break because I
 really don't know how to do this. I've read some articles that say
 more then 1 level deep is not a good idea but I don't how to make sure
 records aren't viewed by other users that they didn't create. I've
 bought more book then I probably should and am getting frustrated.
 Maybe my method of making sure records are not viewed by other users
 is the wrong approach.


I am still confused about your model relationships.  Could you post
the class definitions please showing the has and belongs to
relationships?

Colin

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Ordered Sets in Ruby

2009-09-20 Thread Fidel Viegas

Hi Litwin,

Thanks a lot for the link.

I will give it a try, but from what I saw that is exactly what I am looking for.

Regards,

Fidel.

On Sun, Sep 20, 2009 at 1:28 AM, E. Litwin elit...@rocketmail.com wrote:

 Take a look at acts_as_list - http://github.com/rails/acts_as_list

 On Sep 19, 4:25 pm, Fidel Viegas fidel.vie...@gmail.com wrote:
 Hi Rob,

 Thanks for the reply. I have managed to get this code done. What I
 wanted really was how to save and update.

 For instance, I want to know how to create the instance of the
 invoice, and the invoice lines. When updating the invoice, its line
 items with the respective order should be also updated in the db.

 If I remove one item from the list, the order of each item should be 
 adjusted.

 Let's say I have the following invoiceitems:

 item, qty, price, order
 1, 3, 12.0, 1
 6, 1, 23.0, 2
 3, 2, 11.0, 3

 if I remove item with order 2, I should get the following:

 1, 3, 12.0, 1
 3, 2, 11.0, 2

 What I am after is a view + controller solution.

 Thanks in advance.

 Regards,

 Fidel.

 On Sat, Sep 19, 2009 at 11:59 PM, Rob Biedenharn

 r...@agileconsultingllc.com wrote:

  On Sep 19, 2009, at 5:35 PM, Fidel Viegas wrote:
  Hi all,

  I am implementing a simple invoice system where I have invoiceLines,
  and where I want to keep the order of the lines. I have tried to
  google around but have not found any sample on this.

  Can someone give me a pointer to something that uses a set where the
  order is kept?

  Thanks in advance.

  Regards,

  Fidel.

  Well, that would be an Array. Or in the likely case that your data is
  accessed with ActiveRecord models, an AssociationProxy that will
  behave mostly like an Array.  You will probably find something like
  the following in any reasonable discussion about the has_many/
  belongs_to associations. If you don't specify a default order for the
  association, then you'll get the invoice_lines back in whatever order
  the database prefers (often the order in which the database records
  were created).

  ## Models
  class Invoice  ActiveRecord::Base
    has_many :invoice_lines, :order = 'line_number'
  end
  class InvoiceLine  ActiveRecord::Base
    belongs_to :invoice
  end

  ## migration (schema)
  create_table :invoices do |t|
    t.integer :number
    t.date    :inv_date
    t.date    :due_date
    # etc.
  end

  create_table :invoice_lines do |t|
    t.references :invoice
    # equiv. to  t.integer :invoice_id
    t.integer    :line_number
    t.string     :sku
    t.integer    :quantity
    t.decimal    :unit_price, :precision = 8, :scale = 2
    # etc.
  end

  ## use in a controller

  @invoice = Invoice.find_by_number(params[:invoice][:number])

  @invoice.invoice_lines
  #= an array-like set of InvoiceLine records

  -Rob

  Rob Biedenharn          http://agileconsultingllc.com
  r...@agileconsultingllc.com


 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: render :partial = @object

2009-09-20 Thread Wang Pengcheng
%=render :partial=@styles %
the partial html is :
_style.html.erb
and the object can be used in the partial erb is style

2009/9/20 Me chabg...@gmail.com


 renders nothing.

 On Sep 20, 12:13 am, Wang Pengcheng wpc0...@gmail.com wrote:
  Add a comma or not?
  %=render :partial, @styles %
 
  2009/9/20 Me chabg...@gmail.com
 
 
 
 
 
   Running rails  2.1.0 when I do this:
 
   %= render :partial = 'style', :collection = @styles %
 
   I get the collection fine in my index file.  When I try the shortcut:
 
   %= render :partial  @styles %
 
   I get this error:
 
   Couldn't find template file for active_record/named_scope/scopes/
   _scope
 
   Any ideas??
 
  --
  Code our future
  Name   : Wang Pengcheng
  Nick : QJGui
 



-- 
Code our future
Name   : Wang Pengcheng
Nick : QJGui

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Ensuring a password is Alpha-Numeric

2009-09-20 Thread Wang Pengcheng
Thanks for your words.
I am sorry for my words.
/\A[\d\w]+\Z/im

2009/9/20 Felix Schäfer schae...@cypres-it.com



 Am 20.09.2009 um 05:46 schrieb Wang Pengcheng:

  First , please use the white list not the black list in the regex.
  Second, please validate the length of the input data.
 
  /^[\d\w]+$/i

 As a side note, and if you insist on being pedantic, I'd suggest using
 \A and \Z to delimit the beginning and the end of the whole string in
 the regex, as opposed to ^ and $ only matching the beginning and the
 end of a line in ruby, who knows, maybe one your users will try to use
 a password with a newline in it ;-)

 Felix

 



-- 
Code our future
Name   : Wang Pengcheng
Nick : QJGui

Sent from Wuhan, 42, China

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Ensuring a password is Alpha-Numeric

2009-09-20 Thread Colin Law

2009/9/20 Wang Pengcheng wpc0...@gmail.com:
 Thanks for your words.
 I am sorry for my words.
 /\A[\d\w]+\Z/im

I think the point of the OP's post was that he wanted the user to have
to enter alphabetic _and_ numeric characters, not to limit them to
only those characters.

Colin


 2009/9/20 Felix Schäfer schae...@cypres-it.com


 Am 20.09.2009 um 05:46 schrieb Wang Pengcheng:

  First , please use the white list not the black list in the regex.
  Second, please validate the length of the input data.
 
  /^[\d\w]+$/i

 As a side note, and if you insist on being pedantic, I'd suggest using
 \A and \Z to delimit the beginning and the end of the whole string in
 the regex, as opposed to ^ and $ only matching the beginning and the
 end of a line in ruby, who knows, maybe one your users will try to use
 a password with a newline in it ;-)

 Felix





 --
 Code our future
 Name   : Wang Pengcheng
 Nick     : QJGui

 Sent from Wuhan, 42, China

 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] rails CMS - which is most stable simplest at the moment? (i.e. has a solid following)

2009-09-20 Thread Greg Hauptmann

Hi - there quite a few Ruby on Rails CMS's out there.  Can anyone give
a picture of which are the most supported/worked on at the moment
(i.e. most likely to have a long life)?   Just after a simple CMS...

thanks

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] simplest CMS design question

2009-09-20 Thread Greg Hauptmann

Hi all,

What would be the best design if I wanted a RubyOnRails basic CMS that
would allow HTML/images to be uploaded and viewed by users who were
allowed to see them.  In particular what would be a good / robust way
to host the files?   For example:

a) Let Apache web server (i.e. not RoR engine) host them - this would
require RoR could save the files out on the Unix/Linux box to an
approach location under the web server (not sure how possible this
is).  Also it means that user management would need to be
integrated/handled by Apache (could be an issue perhaps?)

b) Let RoR application store them in it's own directory area, but not
under the /public directory as this could be visible on web for the
right URL - once stored on file, then the image tag URL in the HTML
pages would need to tell the RoR application to get them via a
specific controller/action which would then have to retrieve them and
stream them out...

c) As per b) above but stored in a mysql database







-- 
Greg
http://blog.gregnet.org/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: simplest CMS design question

2009-09-20 Thread Peter De Berdt

On 20 Sep 2009, at 13:14, Greg Hauptmann wrote:

 What would be the best design if I wanted a RubyOnRails basic CMS that
 would allow HTML/images to be uploaded and viewed by users who were
 allowed to see them.  In particular what would be a good / robust way
 to host the files?   For example:

 a) Let Apache web server (i.e. not RoR engine) host them - this would
 require RoR could save the files out on the Unix/Linux box to an
 approach location under the web server (not sure how possible this
 is).  Also it means that user management would need to be
 integrated/handled by Apache (could be an issue perhaps?)

 b) Let RoR application store them in it's own directory area, but not
 under the /public directory as this could be visible on web for the
 right URL - once stored on file, then the image tag URL in the HTML
 pages would need to tell the RoR application to get them via a
 specific controller/action which would then have to retrieve them and
 stream them out...

 c) As per b) above but stored in a mysql database

I'd go for Apache with the mod X-Sendfile compiled into it. There's an  
option in the latest Rails version afaik to use it out of the box and  
in previous versions it's just a matter of installing a plugin or  
crafting the headers yourself. It basically comes down to handling  
authentication etc with Rails and serving the file through Apache  
directly using a special header.

http://www.google.com/search?client=safarirls=enq=rails+2.3+x+sendfileie=UTF-8oe=UTF-8


Best regards

Peter De Berdt


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: finding bbcode plugin..

2009-09-20 Thread Fall-From-Grace

^^^
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Stream rubyzip

2009-09-20 Thread Mark Dodwell

I'd be interested to know if you got anywhere with this?
-- 
Posted via http://www.ruby-forum.com/.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] rake tasks

2009-09-20 Thread Thufir

I'm not really creating a rails app, but may integrate this with rails 
down the road.

I've adapted rss2mysql.rb from:

Practical Ruby Gems
http://www.apress.com/book/view/9781590598115

Chapter 10, parsing feeds

but am tweaking everything.  Currently I have a rakefile, but am a bit 
unclear about what sort of tasks go in there.  For instance, grabbing rss 
data from the interwebs could be a task, so maybe it should go in the 
rake file?

Also, the rake file should have provisions to add/drop tables?

I started to put some of the db interactions into the rakefile, and then 
thought that maybe everything in this file (script?) belongs in a 
rakefile. Where do you draw the line?


thu...@arrakis:~/rb$ 
thu...@arrakis:~/rb$ cat rss2mysql.rb 
require 'rubygems'
require 'active_record'
require 'feed_tools'
require 'yaml'

db = YAML.load_file(database.yml)
ActiveRecord::Base.establish_connection(
  :adapter  = db[adapter],
  :host = db[host],
  :username = db[username],
  :password = db[password],
  :database = db[database])
class Item   ActiveRecord::Base
end

unless Item.table_exists?
  ActiveRecord::Schema.define do
create_table :items do |t|
t.column :title, :string
t.column :content, :string
t.column :source, :string
t.column :url, :string
t.column :timestamp, :timestamp
t.column :keyword_id, :integer
t.column :guid, :string
t.column :html, :string
  end
  end
end

puts connected


#feed = FeedTools::Feed.open('http://www.slashdot.org/index.rss')
feed = FeedTools::Feed.open('www.amazon.com/rss/tag/blu-ray/new')

feed.items.each do |feed_item|
  if not (Item.find_by_title(feed_item.title)  \
or Item.find_by_url(feed_item.link)\
or Item.find_by_guid(feed_item.guid))
  puts processing item '#{feed_item.title}' - new

Items.new do |newitem|
   newitem.title=feed_item.title.gsub(/[^]*/, '')
   newitem.guid=feed_item.guid
   if feed_item.publisher.name
   newitem.source=feed_item.publisher.name
   end
   newitem.url=feed_item.link
   newitem.content=feed_item.description
   newitem.timestamp=feed_item.published
   newitem.save
end
  else
puts processing item '#{feed_item.title}' - old
  end
end


thu...@arrakis:~/rb$ 



Also, what sort of IDE is popular for ruby?  Eclipse?


thanks,

Thufir


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: coordinates for geokit

2009-09-20 Thread sax

I think geokit wants lat,lng as floats (or something it can easily
convert into floats with to_f). It's hard to tell from the API whether
distance_from is processed in rails or using SQL trig functions. Since
geokit does a lot of processing on the database side rather than in
rails, it may be easier if you can find some way to store your data in
that format.

Also: this may be get you more expert help with geokit:
http://groups.google.com/group/geokit


On Sep 20, 12:19 am, bingo bob rails-mailing-l...@andreas-s.net
wrote:
 Someone said i can convert these with a regex ? that right ?

 Maybe on the fly ?
 --
 Posted viahttp://www.ruby-forum.com/.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Ensuring a password is Alpha-Numeric

2009-09-20 Thread Wang Pengcheng
I am sorry to misunderstanding the author's needing.
Waiting for solving.
:-)

2009/9/20 Colin Law clan...@googlemail.com


 2009/9/20 Wang Pengcheng wpc0...@gmail.com:
  Thanks for your words.
  I am sorry for my words.
  /\A[\d\w]+\Z/im

 I think the point of the OP's post was that he wanted the user to have
 to enter alphabetic _and_ numeric characters, not to limit them to
 only those characters.

 Colin

 
  2009/9/20 Felix Schäfer schae...@cypres-it.com
 
 
  Am 20.09.2009 um 05:46 schrieb Wang Pengcheng:
 
   First , please use the white list not the black list in the regex.
   Second, please validate the length of the input data.
  
   /^[\d\w]+$/i
 
  As a side note, and if you insist on being pedantic, I'd suggest using
  \A and \Z to delimit the beginning and the end of the whole string in
  the regex, as opposed to ^ and $ only matching the beginning and the
  end of a line in ruby, who knows, maybe one your users will try to use
  a password with a newline in it ;-)
 
  Felix
 
 
 
 
 
  --
  Code our future
  Name   : Wang Pengcheng
  Nick : QJGui
 
  Sent from Wuhan, 42, China
 
  
 

 



-- 
Code our future
Name   : Wang Pengcheng
Nick : QJGui

Sent from Wuhan, 42, China

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: What's the correct way to delete old sessions

2009-09-20 Thread TRBNGR

Thx for the input guys, yea Im also not sure why I would want to run
the session removal on a random basis, it seems like using script/
runner is the way Im gonna go. I can't put it into the authorization,
fwiw because the application doesn't have any authorization layer. Im
gonna look into the scheduling gem.

On Sep 19, 6:45 am, Peter De Berdt peter.de.be...@pandora.be wrote:
 On 18 Sep 2009, at 21:01, Greg Donald wrote:

  That will be processed for every request,

  No it won't.  It has randomization code that causes it to not run
  _most of the time_.  This is exactly how session gc should be handled.
  It will ramp up proportionally with traffic.

 Actually that could be never or always, relying on random numbers to  
 make decisions on whether to do something most of the time is a bad  
 idea.

 The pointers that were given by Sax were more valid options. I'd  
 personally prefer the cron tab option, since you can run it on a  
 regular and low activity time, it's built-in and already running on  
 any unix-based OS and thus requires no extra processes. It could even  
 be a little script that runs outside of Rails, since it's a bit of  
 overkill to start a whole Rails instance just to delete some records  
 in the sessions table.

 Best regards

 Peter De Berdt
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: find with join over aggregated

2009-09-20 Thread bitrocker

Well,

I could figure out hoe to do it: Using :joins (without :include) and
the proper table aliases works
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: What's the correct way to delete old sessions

2009-09-20 Thread Colin Law

2009/9/18 Peter De Berdt peter.de.be...@pandora.be:

 On 18 Sep 2009, at 21:01, Greg Donald wrote:

 That will be processed for every request,

 No it won't.  It has randomization code that causes it to not run
 _most of the time_.  This is exactly how session gc should be handled.
 It will ramp up proportionally with traffic.

 Actually that could be never or always, relying on random numbers to make
 decisions on whether to do something most of the time is a bad idea.

Since quantum physics works entirely by probabilities (that is random
numbers) and microprocessors are built from semi-conductors which
operate because of the laws of quantum physics, it could be said that
any software is entirely dependent on the operation of random numbers.
 Therefore however it is coded it is 'relying on random numbers to
make decisions on whether to do something'.

Seriously, though, to suggest that something coded using random
numbers to be executed 1% of the time may either never run or always
run is incorrect.  Assuming it is correctly coded of course.

Colin

 The pointers that were given by Sax were more valid options. I'd personally
 prefer the cron tab option, since you can run it on a regular and low
 activity time, it's built-in and already running on any unix-based OS and
 thus requires no extra processes. It could even be a little script that runs
 outside of Rails, since it's a bit of overkill to start a whole Rails
 instance just to delete some records in the sessions table.

 Best regards

 Peter De Berdt

 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Validation fails but objects seems to have the values

2009-09-20 Thread PanosJee

Hello everyone i am trying to save a nested model but it will always
fail because 2 fields are missing
I tried to examine what happens so i print the object to yaml, here s
what i got:

- id001 !ruby/object:Contract
  attributes:
price:
room_id:
start_date: 15/09/2009
created_at:
is_consecutive: false
same_sex: false
comments:
updated_at:
has_keys: false
touched_by:
amount_to_keep: 0
house_id:
user_id: 0
paid_percent: 0.0
has_signed: false
shared: true
house_rating: 0
deposit_returned: false
service_rating: 0
booking_date:
end_date: 14/02/2010
active: false
  attributes_cache:
start_date:
end_date:
  changed_attributes: {}

  errors: !ruby/object:ActiveRecord::Errors
base: *id001
errors:
  base:
  - !ruby/object:ActiveRecord::Error
attribute: :base
base: *id001
message: Please tell us when your rental period should start
options: {}

type: Please tell us when your rental period should start
  - !ruby/object:ActiveRecord::Error
attribute: :base
base: *id001
message: Please tell us when your rental period should end
options: {}

type: Please tell us when your rental period should end
  new_record: true

The only fields that i am checking for presence are the start_date and
end_date as you can see in the yaml they have a value but then
validation fails.

Thanx a lot for your time
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: render :partial = @object

2009-09-20 Thread Chris Habgood
ya that is what I have.

On Sun, Sep 20, 2009 at 3:56 AM, Wang Pengcheng wpc0...@gmail.com wrote:

 %=render :partial=@styles %
 the partial html is :
 _style.html.erb
 and the object can be used in the partial erb is style

 2009/9/20 Me chabg...@gmail.com


 renders nothing.

 On Sep 20, 12:13 am, Wang Pengcheng wpc0...@gmail.com wrote:
  Add a comma or not?
  %=render :partial, @styles %
 
  2009/9/20 Me chabg...@gmail.com
 
 
 
 
 
   Running rails  2.1.0 when I do this:
 
   %= render :partial = 'style', :collection = @styles %
 
   I get the collection fine in my index file.  When I try the shortcut:
 
   %= render :partial  @styles %
 
   I get this error:
 
   Couldn't find template file for active_record/named_scope/scopes/
   _scope
 
   Any ideas??
 
  --
  Code our future
  Name   : Wang Pengcheng
  Nick : QJGui




 --
 Code our future
 Name   : Wang Pengcheng
 Nick : QJGui



 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Really stuck on nested resources

2009-09-20 Thread MichaelB

Hey mlttle-

You can create a new dog with:

def create
  @dog = Parent.find(params[:parent_id]).children.find(params
[:child_id]).dogs.create
end

The console is your best friend to quickly diagnose errors:

 @record= parent.child.dog.build(params[:dog])
NoMethodError: undefined method `child' for #Parent:0x22b6748

.. becuase your parent model has many **children**

 @record= parent.children.find(child).dogs.build(params[:dog])

Michael



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: partial wont render .html.erb

2009-09-20 Thread pepe

My guess is that your syntax is incorrect and you are missing the name
of the partial to render itself and also either the :object
or :collection symbols.

This is from the documentation to rendering partials, in case it
helps:

  # Renders the same partial with a local variable.
  render :partial = person, :locals = { :name = david }

  # Renders the partial, making @new_person available through
  # the local variable 'person'
  render :partial = person, :object = @new_person

  # Renders a collection of the same partial by making each element
  # of @winners available through the local variable person as it
  # builds the complete response.
  render :partial = person, :collection = @winners

  # Renders a collection of partials but with a custom local variable
name
  render :partial = admin_person, :collection = @winners, :as
= :person

  # Renders the same collection of partials, but also renders the
  # person_divider partial between each person partial.
  render :partial = person, :collection =
@winners, :spacer_template = person_divider

  # Renders a collection of partials located in a view subfolder
  # outside of our current controller.  In this example we will be
  # rendering app/views/shared/_note.r(html|xml)  Inside the partial
  # each element of @new_notes is available as the local var note.
  render :partial = shared/note, :collection = @new_notes

  # Renders the partial with a status code of 500 (internal error).
  render :partial = broken, :status = 500


On Sep 19, 7:50 am, Joe j...@dev-hq.co.uk wrote:
 Hi, My partial simply wont render a .html.erb file. This is exactly
 what I get on the error screen:

  ActionView::MissingTemplate in Categories#show

 Showing app/views/categories/show.html.erb where line #7 raised:

 Missing template tutorials/_tutorial.erb in view path app/views

 Extracted source (around line #7):

 4: /p
 5: h2Tutorials/h2
 6: div id=tutorials
 7:      %= render :partial = @category.tutorials %
 8: /div
 9:
 10: h2New Tutorial/h2

 RAILS_ROOT: C:/rails_apps/DevHQ
 Application Trace | Framework Trace | Full Trace

 C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_view/
 paths.rb:66:in `find_template'
 C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_view/
 partials.rb:236:in `_unmemoized__pick_partial_template'
 C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/
 memoizable.rb:84:in `_pick_partial_template'
 C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_view/
 partials.rb:219:in `render_partial_collection'
 C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
 associations/association_collection.rb:364:in `method_missing'
 C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
 associations/association_proxy.rb:219:in `method_missing'
 C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
 associations/association_proxy.rb:219:in `map'
 C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
 associations/association_proxy.rb:219:in `send'
 C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
 associations/association_proxy.rb:219:in `method_missing'
 C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
 associations/association_collection.rb:364:in `method_missing'
 C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_view/
 partials.rb:216:in `render_partial_collection'
 C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_view/
 partials.rb:195:in `render_partial'
 C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_view/
 base.rb:262:in `render'
 C:/rails_apps/DevHQ/app/views/categories/show.html.erb:7:in
 `_run_erb_app47views47categories47show46html46erb'
 C:/rails_apps/DevHQ/app/controllers/categories_controller.rb:18:in
 `show'

 C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_view/
 paths.rb:66:in `find_template'
 C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_view/
 partials.rb:236:in `_unmemoized__pick_partial_template'
 C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/
 memoizable.rb:84:in `_pick_partial_template'
 C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_view/
 partials.rb:219:in `render_partial_collection'
 C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
 associations/association_collection.rb:364:in `method_missing'
 C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
 associations/association_proxy.rb:219:in `method_missing'
 C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
 associations/association_proxy.rb:219:in `map'
 C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
 associations/association_proxy.rb:219:in `send'
 C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
 associations/association_proxy.rb:219:in `method_missing'
 C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
 

[Rails] Re: What's the correct way to delete old sessions

2009-09-20 Thread Peter De Berdt

On 20 Sep 2009, at 17:09, Colin Law wrote:

 Actually that could be never or always, relying on random numbers  
 to make
 decisions on whether to do something most of the time is a bad  
 idea.

 Since quantum physics works entirely by probabilities (that is random
 numbers) and microprocessors are built from semi-conductors which
 operate because of the laws of quantum physics, it could be said that
 any software is entirely dependent on the operation of random numbers.
 Therefore however it is coded it is 'relying on random numbers to
 make decisions on whether to do something'.

 Seriously, though, to suggest that something coded using random
 numbers to be executed 1% of the time may either never run or always
 run is incorrect.  Assuming it is correctly coded of course.

Well, since you are going on the philosophical tour here, there's more  
than one random variable coming into play here. Not only the mod 10  
result, but also the number of hits on the application, the time at  
which they hit the application etc. That's not even playing with  
probabities, that's just plain gambling.

All I was trying to point out, is that you have no way of knowing if  
and when the sessions table would be cleaned, just like you have no  
way of knowing if you have a chance of winning a game of bingo or the  
lotto, since you are bringing in a lot more variables than just the  
semi-random computer generated ones. You could hit it the first time,  
you could hit it twice in a row and you could wait days to hit it. The  
fact that you have a 10% chance or a 1% chance of hitting the right  
number is still a probability, not a certainty. When it comes to  
cleaning a table that just keeps piling up records that become stale,  
I do like to have some kind of guarantee that it will clean when I  
want it, not when quantum physics and random people surfing to my  
application decide it's the right time.

Best regards

Peter De Berdt


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: render :partial = @object

2009-09-20 Thread Chris Habgood
Ya if I change it to the normal :collection style syntax it works fine.

On Sun, Sep 20, 2009 at 11:08 AM, Colin Law clan...@googlemail.com wrote:


 2009/9/20 Chris Habgood chabg...@gmail.com:
  ya that is what I have.
 
  On Sun, Sep 20, 2009 at 3:56 AM, Wang Pengcheng wpc0...@gmail.com
 wrote:
 
  %=render :partial=@styles %
  the partial html is :
  _style.html.erb
  and the object can be used in the partial erb is style
 
  2009/9/20 Me chabg...@gmail.com
 
  renders nothing.

 You could use ruby-debug to break into the partial to check it is
 getting there.  Another thing to do is to check the html produced
 (view source in browser) to check that it is in fact generating
 nothing, rather than just nothing that displays.

 Presumably you have checked that @styles is not empty?

 Colin

 
  On Sep 20, 12:13 am, Wang Pengcheng wpc0...@gmail.com wrote:
   Add a comma or not?
   %=render :partial, @styles %
  
   2009/9/20 Me chabg...@gmail.com
  
  
  
  
  
Running rails  2.1.0 when I do this:
  
%= render :partial = 'style', :collection = @styles %
  
I get the collection fine in my index file.  When I try the
 shortcut:
  
%= render :partial  @styles %
  
I get this error:
  
Couldn't find template file for active_record/named_scope/scopes/
_scope
  
Any ideas??
  
   --
   Code our future
   Name   : Wang Pengcheng
   Nick : QJGui
 
 
 
 
  --
  Code our future
  Name   : Wang Pengcheng
  Nick : QJGui
 
 
 
 
 
 
  
 

 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: render :partial = @object

2009-09-20 Thread Colin Law

2009/9/20 Chris Habgood chabg...@gmail.com:
 ya that is what I have.

 On Sun, Sep 20, 2009 at 3:56 AM, Wang Pengcheng wpc0...@gmail.com wrote:

 %=render :partial=@styles %
 the partial html is :
 _style.html.erb
 and the object can be used in the partial erb is style

 2009/9/20 Me chabg...@gmail.com

 renders nothing.

You could use ruby-debug to break into the partial to check it is
getting there.  Another thing to do is to check the html produced
(view source in browser) to check that it is in fact generating
nothing, rather than just nothing that displays.

Presumably you have checked that @styles is not empty?

Colin


 On Sep 20, 12:13 am, Wang Pengcheng wpc0...@gmail.com wrote:
  Add a comma or not?
  %=render :partial, @styles %
 
  2009/9/20 Me chabg...@gmail.com
 
 
 
 
 
   Running rails  2.1.0 when I do this:
 
   %= render :partial = 'style', :collection = @styles %
 
   I get the collection fine in my index file.  When I try the shortcut:
 
   %= render :partial �...@styles %
 
   I get this error:
 
   Couldn't find template file for active_record/named_scope/scopes/
   _scope
 
   Any ideas??
 
  --
  Code our future
  Name   : Wang Pengcheng
  Nick     : QJGui




 --
 Code our future
 Name   : Wang Pengcheng
 Nick     : QJGui






 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Calculating business day

2009-09-20 Thread pepe

Sorry, I should also have added to take a look at
ActiveSupport::CoreExtensions::Numeric::Time, which allows something
like 1.week.from_now, 1.week.ago, etc.

On Sep 19, 6:32 pm, pepe p...@betterrpg.com wrote:
 For the holidays you are going to need to store them somewhere as was
 already pointed out in another post since they might even vary by
 company. Calculating the weekend days should be easy using the
 extended functionality for dates that Rails offers. You can check the
 ActiveSupport::CoreExtensions::DateTime::* and
 ActiveSupport::CoreExtensions::Date* modules for that.

 Good luck.

 On Sep 18, 2:17 pm, Penelope West rails-mailing-l...@andreas-s.net
 wrote:

  I want calculate the number of business day for the current month, but I
  don't know how I skip the holidays and weekends.

  Could anyone help me with this?

  Thanks
  --
  Posted viahttp://www.ruby-forum.com/.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: render :partial = @object

2009-09-20 Thread Chris Habgood
Everything is in the styles views directory.  rails 2.1.0.  I am very
confused as this sytnax is supposed to be supported by rails  2.0.  I even
tried it in 2.3.2 and the same thing.  I watched ryan bates railscasts about
4 times and I still do not know why it is not working.

This works fine:

%= render :partial = 'style', :collection = @styles %

Which is even more bewildering.

On Sun, Sep 20, 2009 at 11:41 AM, Colin Law clan...@googlemail.com wrote:


 2009/9/20 Chris Habgood chabg...@gmail.com:
  Ya if I change it to the normal :collection style syntax it works fine.


 Ah, I see, I had misunderstood the problem.  Is @styles an array of
 Style objects, and are you rendering from the style controller?  Where
 is _style.html.erb?

 What version of Rails are you using?  I don't know what version that
 syntax appeared.  Anyone?

 Colin

 
  On Sun, Sep 20, 2009 at 11:08 AM, Colin Law clan...@googlemail.com
 wrote:
 
  2009/9/20 Chris Habgood chabg...@gmail.com:
   ya that is what I have.
  
   On Sun, Sep 20, 2009 at 3:56 AM, Wang Pengcheng wpc0...@gmail.com
   wrote:
  
   %=render :partial=@styles %
   the partial html is :
   _style.html.erb
   and the object can be used in the partial erb is style
  
   2009/9/20 Me chabg...@gmail.com
  
   renders nothing.
 
  You could use ruby-debug to break into the partial to check it is
  getting there.  Another thing to do is to check the html produced
  (view source in browser) to check that it is in fact generating
  nothing, rather than just nothing that displays.
 
  Presumably you have checked that @styles is not empty?
 
  Colin
 
  
   On Sep 20, 12:13 am, Wang Pengcheng wpc0...@gmail.com wrote:
Add a comma or not?
%=render :partial, @styles %
   
2009/9/20 Me chabg...@gmail.com
   
   
   
   
   
 Running rails  2.1.0 when I do this:
   
 %= render :partial = 'style', :collection = @styles %
   
 I get the collection fine in my index file.  When I try the
 shortcut:
   
 %= render :partial  @styles %
   
 I get this error:
   
 Couldn't find template file for
 active_record/named_scope/scopes/
 _scope
   
 Any ideas??
   
--
Code our future
Name   : Wang Pengcheng
Nick : QJGui
  
  
  
  
   --
   Code our future
   Name   : Wang Pengcheng
   Nick : QJGui
  
  
  
  
  
  
   
  
 
 
 
 
  
 

 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: rake tasks

2009-09-20 Thread Thufir

On Sun, 20 Sep 2009 12:17:05 +, Thufir wrote:

 I'm not really creating a rails app, but may integrate this with rails
 down the road.
 
 I've adapted rss2mysql.rb from:
 
 Practical Ruby Gems
 http://www.apress.com/book/view/9781590598115
 
 Chapter 10, parsing feeds

I broke that code into three rake tasks:

thu...@arrakis:~/rb$ 
thu...@arrakis:~/rb$ rake --tasks
(in /home/thufir/rb)
rake connect   # connects to db
rake exists# creates table unless it already exists
rake populate  # gets rss data
thu...@arrakis:~/rb$ 

so that exists and populate depend upon the connect task.  Is this 
reasonably compatible with RoR?



thanks,

Thufir


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: partial wont render .html.erb

2009-09-20 Thread Colin Law

2009/9/19 Joe j...@dev-hq.co.uk:

 Yes..

Is it definitely in views/tutorials rather than views/categories?

Does the alternative syntax work:
render :partial = tutorials/tutorial, :collection = @category.tutorials

Colin


 On Sep 19, 1:53 pm, Colin Law clan...@googlemail.com wrote:
 2009/9/19 Joe j...@dev-hq.co.uk:



  Hi, My partial simply wont render a .html.erb file. This is exactly
  what I get on the error screen:

   ActionView::MissingTemplate in Categories#show

  Showing app/views/categories/show.html.erb where line #7 raised:

  Missing template tutorials/_tutorial.erb in view path app/views

 Have you got a tutorials/_tutorial.erb in app/views?

 Colin



  Extracted source (around line #7):

  4: /p
  5: h2Tutorials/h2
  6: div id=tutorials
  7:      %= render :partial = @category.tutorials %
  8: /div
  9:
  10: h2New Tutorial/h2

 snip
 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: render :partial = @object

2009-09-20 Thread Colin Law

2009/9/20 Chris Habgood chabg...@gmail.com:
 Ya if I change it to the normal :collection style syntax it works fine.


Ah, I see, I had misunderstood the problem.  Is @styles an array of
Style objects, and are you rendering from the style controller?  Where
is _style.html.erb?

What version of Rails are you using?  I don't know what version that
syntax appeared.  Anyone?

Colin


 On Sun, Sep 20, 2009 at 11:08 AM, Colin Law clan...@googlemail.com wrote:

 2009/9/20 Chris Habgood chabg...@gmail.com:
  ya that is what I have.
 
  On Sun, Sep 20, 2009 at 3:56 AM, Wang Pengcheng wpc0...@gmail.com
  wrote:
 
  %=render :partial=@styles %
  the partial html is :
  _style.html.erb
  and the object can be used in the partial erb is style
 
  2009/9/20 Me chabg...@gmail.com
 
  renders nothing.

 You could use ruby-debug to break into the partial to check it is
 getting there.  Another thing to do is to check the html produced
 (view source in browser) to check that it is in fact generating
 nothing, rather than just nothing that displays.

 Presumably you have checked that @styles is not empty?

 Colin

 
  On Sep 20, 12:13 am, Wang Pengcheng wpc0...@gmail.com wrote:
   Add a comma or not?
   %=render :partial, @styles %
  
   2009/9/20 Me chabg...@gmail.com
  
  
  
  
  
Running rails  2.1.0 when I do this:
  
%= render :partial = 'style', :collection = @styles %
  
I get the collection fine in my index file.  When I try the
shortcut:
  
%= render :partial �...@styles %
  
I get this error:
  
Couldn't find template file for active_record/named_scope/scopes/
_scope
  
Any ideas??
  
   --
   Code our future
   Name   : Wang Pengcheng
   Nick     : QJGui
 
 
 
 
  --
  Code our future
  Name   : Wang Pengcheng
  Nick     : QJGui
 
 
 
 
 
 
  
 




 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Mysql Can't Connect

2009-09-20 Thread Kevin M

@Mukund To answer your question:
Yes, I used db:migrate to build the database, then I used phpmyadmin
to see what the result was, I'm new to rails programming and thought
it would be useful to examine the result.

I think I have the connection to the database correct, the problem
appears (to me) to be in the setup before I migrate.

I'm doing the restful_authentication with all the bells  whistles
tutorial. I started over again to go from the beginning. When I get to
the migration I get an error, here's the initial error and the full
trace:

ERROR:

==  SetUpFirstAdminUser: migrating

rake aborted!
An error has occurred, all later migrations canceled:

You have a nil object when you didn't expect it!
The error occurred while evaluating nil.activated_at=

FULL TRACE:
-
(in /Users/Me/Sites/RAT2/restful_authentication_tutorial)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
==  SetUpFirstAdminUser: migrating

rake aborted!
An error has occurred, all later migrations canceled:

Mysql::Error: Duplicate entry 'userDEV' for key 2: INSERT INTO `users`
(`name`, `salt`, `updated_at`, `activated_at`, `crypted_password`,
`remember_token_expires_at`, `activation_code`, `password_reset_code`,
`enabled`, `invitation_id`, `user_type`, `remember_token`,
`identity_url`, `login`, `email`, `created_at`, `invitation_limit`)
VALUES('', '1a9bde41a2d6d664d03e32676c479a07f301d2a6', '2009-09-20
16:23:19', NULL, 'b984b8c4f7258b854fab69f85c8b2a95116b41c9', NULL,
'1194519fe5c980f38f0d8ffd77f2c8b94625af2b', NULL, 1, NULL, 'SiteUser',
NULL, NULL, 'userDEV', NULL, '2009-09-20 16:23:19', 5)
/Users/Me/Sites/RAT2/restful_authentication_tutorial/vendor/plugins/
rows_logger/init.rb:36:in `log'
/Users/Me/Sites/RAT2/restful_authentication_tutorial/vendor/rails/
activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:
320:in `execute_without_analyzer'
/Users/Me/Sites/RAT2/restful_authentication_tutorial/vendor/plugins/
footnotes/lib/rails-footnotes/notes/queries_note.rb:104:in
`execute_without_query_stats'
/Users/Me/Sites/RAT2/restful_authentication_tutorial/vendor/rails/
activesupport/lib/active_support/core_ext/benchmark.rb:10:in
`realtime'
/Users/Me/Sites/RAT2/restful_authentication_tutorial/vendor/plugins/
footnotes/lib/rails-footnotes/notes/queries_note.rb:104:in
`execute_without_query_stats'
/Users/Me/Sites/RAT2/restful_authentication_tutorial/vendor/plugins/
query_stats/lib/query_stats/recorder.rb:16:in `execute'
/Users/Me/Sites/RAT2/restful_authentication_tutorial/vendor/rails/
activesupport/lib/active_support/core_ext/benchmark.rb:10:in
`realtime'
/Users/Me/Sites/RAT2/restful_authentication_tutorial/vendor/plugins/
query_stats/lib/query_stats/recorder.rb:15:in `execute'
/Users/Me/Sites/RAT2/restful_authentication_tutorial/vendor/rails/
activerecord/lib/active_record/connection_adapters/abstract/
database_statements.rb:259:in `insert_sql'
/Users/Me/Sites/RAT2/restful_authentication_tutorial/vendor/rails/
activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:
330:in `insert_sql'
/Users/Me/Sites/RAT2/restful_authentication_tutorial/vendor/rails/
activerecord/lib/active_record/connection_adapters/abstract/
database_statements.rb:44:in `insert_without_query_dirty'
/Users/Me/Sites/RAT2/restful_authentication_tutorial/vendor/rails/
activerecord/lib/active_record/connection_adapters/abstract/
query_cache.rb:18:in `insert'
/Users/Me/Sites/RAT2/restful_authentication_tutorial/vendor/rails/
activerecord/lib/active_record/base.rb:2902:in
`create_without_timestamps'
/Users/Me/Sites/RAT2/restful_authentication_tutorial/vendor/rails/
activerecord/lib/active_record/timestamp.rb:29:in
`create_without_callbacks'
/Users/Me/Sites/RAT2/restful_authentication_tutorial/vendor/rails/
activerecord/lib/active_record/callbacks.rb:266:in `create'
/Users/Me/Sites/RAT2/restful_authentication_tutorial/vendor/rails/
activerecord/lib/active_record/base.rb:2868:in
`create_or_update_without_callbacks'
/Users/Me/Sites/RAT2/restful_authentication_tutorial/vendor/rails/
activerecord/lib/active_record/callbacks.rb:250:in `create_or_update'
/Users/Me/Sites/RAT2/restful_authentication_tutorial/vendor/rails/
activerecord/lib/active_record/base.rb:2539:in
`save_without_validation'
/Users/Me/Sites/RAT2/restful_authentication_tutorial/vendor/rails/
activerecord/lib/active_record/validations.rb:1009:in
`save_without_dirty'
/Users/Me/Sites/RAT2/restful_authentication_tutorial/vendor/rails/
activerecord/lib/active_record/dirty.rb:79:in
`save_without_transactions'
/Users/Me/Sites/RAT2/restful_authentication_tutorial/vendor/rails/
activerecord/lib/active_record/transactions.rb:229:in `send'
/Users/Me/Sites/RAT2/restful_authentication_tutorial/vendor/rails/
activerecord/lib/active_record/transactions.rb:229:in
`with_transaction_returning_status'

[Rails] Re: What's the correct way to delete old sessions

2009-09-20 Thread James Englert
I feel like I'm missing a major point here.  Assuming the table is correctly
range partitioned and indexed, most databases should be able to handle
relatively large table sizes.  I agree that is a best practice to archive
old, unused data, but that can likely be done on a monthly basis, or less
often, depending on traffic.  Why would you need to consider a solution that
will ramp up proportionally with traffic?

Jim
http://www.thepeoplesfeed.com/blog

On Sun, Sep 20, 2009 at 11:42 AM, Peter De Berdt
peter.de.be...@pandora.bewrote:


 On 20 Sep 2009, at 17:09, Colin Law wrote:

 Actually that could be never or always, relying on random numbers to make

 decisions on whether to do something most of the time is a bad idea.


 Since quantum physics works entirely by probabilities (that is random
 numbers) and microprocessors are built from semi-conductors which
 operate because of the laws of quantum physics, it could be said that
 any software is entirely dependent on the operation of random numbers.
 Therefore however it is coded it is 'relying on random numbers to
 make decisions on whether to do something'.

 Seriously, though, to suggest that something coded using random
 numbers to be executed 1% of the time may either never run or always
 run is incorrect.  Assuming it is correctly coded of course.


 Well, since you are going on the philosophical tour here, there's more than
 one random variable coming into play here. Not only the mod 10 result, but
 also the number of hits on the application, the time at which they hit the
 application etc. That's not even playing with probabities, that's just plain
 gambling.

 All I was trying to point out, is that you have no way of knowing if and
 when the sessions table would be cleaned, just like you have no way of
 knowing if you have a chance of winning a game of bingo or the lotto, since
 you are bringing in a lot more variables than just the semi-random computer
 generated ones. You could hit it the first time, you could hit it twice in a
 row and you could wait days to hit it. The fact that you have a 10% chance
 or a 1% chance of hitting the right number is still a probability, not a
 certainty. When it comes to cleaning a table that just keeps piling up
 records that become stale, I do like to have some kind of guarantee that it
 will clean when I want it, not when quantum physics and random people
 surfing to my application decide it's the right time.

 Best regards


 Peter De Berdt


 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Blowfish crypt in rails app

2009-09-20 Thread Robert Walker

Rob Biedenharn wrote:
 Yes. (Assuming that the algorithms are correctly implemented, of
 course.)

You will also have to make sure you're using the exact same algorithm on 
both sides.

For example OpenSSL on Mac OS X 10.6 contains the following blowfish 
ciphers:
bf
bf-cbc
bf-cfb
bf-ecb
bf-ofb

You will need to determine which of these your blowfish.js file is using 
and match that in your Ruby Code.
-- 
Posted via http://www.ruby-forum.com/.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Pagination issue

2009-09-20 Thread louposk

I do this but i get a systax error. Maybe i'm doing something wrong. I
wrote this:

@cat_products = Product.paginate(:per_page = 5, :page = params
[:page],
 :conditions = {['title like ?' , %#
{params[:search]}%], :category_id = params[:id]},
 :order = 'title')

Any ideas???
Thanx

On Sep 20, 12:05 am, Colin Law clan...@googlemail.com wrote:
 2009/9/19 Kostas L. loup...@gmail.com:





  Hi guys!
  I am using will_paginate in my rails application.
  I want to merge these 2 lines in one:

    �...@cat_products1 = Product.find(:all, :conditions = {:category_id
  = params[:id]})
    �...@cat_products2 = Product.paginate(:per_page = 5, :page = params
  [:page],
                                  :conditions = ['title like ?' , %#
  {params[:search]}%],
                                  :order = 'title')

  I want to paginate using the condition category_id=params[:id]

  Any sollutions???

 Can't you just include the category_id in the conditions for the
 paginate call?  Or am I missing something?

 Colin
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: rails CMS - which is most stable simplest at the moment? (i.e. has a solid following)

2009-09-20 Thread Mohit Sindhwani

Greg Hauptmann wrote:
 Hi - there quite a few Ruby on Rails CMS's out there.  Can anyone give
 a picture of which are the most supported/worked on at the moment
 (i.e. most likely to have a long life)?   Just after a simple CMS...
   
radiant - www.radiantcms.org

Cheers,
Mohit.
9/21/2009 | 1:25 AM.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: render :partial = @object

2009-09-20 Thread Eric

Is there something I'm not getting here? The short form should be
either

render :partial = @foo

-or-

render @foo

I've never seen render :partial @foo

-eric


On Sep 19, 9:44 pm, Me chabg...@gmail.com wrote:
 Running rails  2.1.0 when I do this:

 %= render :partial = 'style', :collection = @styles %

 I get the collection fine in my index file.  When I try the shortcut:

 %= render :partial �...@styles %

 I get this error:

 Couldn't find template file for active_record/named_scope/scopes/
 _scope

 Any ideas??
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] date localization

2009-09-20 Thread arwed

Hi,

I have a model with start_date and end_date and a helper:

def period
  #{start_date} - #{end_date}
end

in my view I have:

%= f.collection_select :schedule_id,
@convention.schedules, :id, :period, {:selected = @schedule.id} %

How can I show :period localized, as %=l ... won't work.

Regards
Arwed
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Polymorphic STI with associations

2009-09-20 Thread Matt Jones



On Sep 19, 7:33 am, robdoan quydoant...@gmail.com wrote:
 As my knowledge, it should be :

[snip]
    def userable_type=(sType)
        super(sType.to_s.classify.constantize.base_class.to_s)
     end
 end


Um, no. If you're needing to do this, you've done something seriously
wrong. This is already supported by :polymorphic = true. Also note
that your solution here will fail if the class associated to the
table (Asset in this case) is more than one level above the class
being stored (ie Asset  Sound  Mp3 will try to find records in a
'sounds' table = FAIL)

--Matt Jones
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Routes and urls: www.example.com

2009-09-20 Thread Matt Jones

You might want to try:

map.widget '/widget/show/*url', :controller = 'widget', :action =
'show'

and see if that works. I seem to recall that the dots are the issue,
as the router typically uses them to separate formats from request
params.

--Matt Jones

On Sep 19, 11:04 pm, Richard Schneeman rails-mailing-l...@andreas-
s.net wrote:
 I'm building an application that stores links, but i've run into a
 problem with routing. If my routes.rb looks like this:

   map.widget '/widget/show/:url', :controller = widget, :action =
 show

 then when i go to /widget/show/www.example.com then i get an error. If
 i change the route to:

   map.widget '/widget/show', :controller = widget, :action = show

 and i enter in /widget/show?url=www.example.comthen everything works
 great, but i'm currious if there is anything i can do to make the first
 routing method work?
 --
 Posted viahttp://www.ruby-forum.com/.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Pagination issue

2009-09-20 Thread Stephen Bartholomew

 @cat_products = Product.paginate(:per_page = 5, :page = params
 [:page],
                                  :conditions = {['title like ?' , %#
 {params[:search]}%], :category_id = params[:id]},
                                  :order = 'title')
You're mixing 2 styles of defining conditions here.  You should be
able to do this:

Product.paginate(:per_page = 5,
 :page = params[:page],
 :conditions = [title LIKE ?, %#{params
[:search]}%, params[:id]],
 :order = 'title')

The :conditions array accepts either a string with ? placeholders
followed by parameters in a list:
[title = ? AND name = ?, arg1, arg2]

or a string with symbol placeholders followed by a hash:
[title = :title AND name = :name, {:title = foo, :name = bar}]

Hope that explains it and helps.

Steve

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: render :partial = @object

2009-09-20 Thread Colin Law

2009/9/20 Eric ericgh...@gmail.com:

 Is there something I'm not getting here? The short form should be
 either

 render :partial = @foo

 -or-

 render @foo

 I've never seen render :partial @foo

OP you have changed it to
%=render :partial=@styles %
as pointed out by Wang Pengcheng?

Colin


 -eric


 On Sep 19, 9:44 pm, Me chabg...@gmail.com wrote:
 Running rails  2.1.0 when I do this:

 %= render :partial = 'style', :collection = @styles %

 I get the collection fine in my index file.  When I try the shortcut:

 %= render :partial �...@styles %

 I get this error:

 Couldn't find template file for active_record/named_scope/scopes/
 _scope

 Any ideas??
 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: date localization

2009-09-20 Thread Colin Law

2009/9/20 arwed a...@bbp.biz:

 Hi,

 I have a model with start_date and end_date and a helper:

 def period
  #{start_date} - #{end_date}

If you want the dates to appear as localised strings you must do it
here.  Formatting them as appropriate as you build the string.  If I
understand the question correctly.

Colin

 end

 in my view I have:

 %= f.collection_select :schedule_id,
 @convention.schedules, :id, :period, {:selected = @schedule.id} %

 How can I show :period localized, as %=l ... won't work.

 Regards
 Arwed
 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Pagination issue

2009-09-20 Thread Colin Law

2009/9/20 Stephen Bartholomew st...@curve21.com:

 @cat_products = Product.paginate(:per_page = 5, :page = params
 [:page],
                                  :conditions = {['title like ?' , %#
 {params[:search]}%], :category_id = params[:id]},
                                  :order = 'title')
 You're mixing 2 styles of defining conditions here.  You should be
 able to do this:

 Product.paginate(:per_page = 5,
                         :page = params[:page],
                         :conditions = [title LIKE ?, %#{params
 [:search]}%, params[:id]],

Should that be :conditions = [title LIKE ? AND category_id = ?, %#{params
 [:search]}%, params[:id]],

Colin

                         :order = 'title')

 The :conditions array accepts either a string with ? placeholders
 followed by parameters in a list:
 [title = ? AND name = ?, arg1, arg2]

 or a string with symbol placeholders followed by a hash:
 [title = :title AND name = :name, {:title = foo, :name = bar}]

 Hope that explains it and helps.

 Steve

 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: date localization

2009-09-20 Thread arwed

Hi Colin,

thanks for your reply.

I defined my date formats in /config/locales/de.yml but I don't know
how to format my dates in my model. In view I can do %=l
@schedule.start_date %.

Can you tell me how I can do that with #{start_date}? The format I
need is dd.mm.yyy

Regards
Arwed


On 20 Sep., 21:46, Colin Law clan...@googlemail.com wrote:
 2009/9/20 arwed a...@bbp.biz:



  Hi,

  I have a model with start_date and end_date and a helper:

  def period
   #{start_date} - #{end_date}

 If you want the dates to appear as localised strings you must do it
 here.  Formatting them as appropriate as you build the string.  If I
 understand the question correctly.

 Colin

  end

  in my view I have:

  %= f.collection_select :schedule_id,
  @convention.schedules, :id, :period, {:selected = @schedule.id} %

  How can I show :period localized, as %=l ... won't work.

  Regards
  Arwed


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: date localization

2009-09-20 Thread Colin Law

2009/9/20 arwed a...@bbp.biz:

 Hi Colin,

 thanks for your reply.

 I defined my date formats in /config/locales/de.yml but I don't know
 how to format my dates in my model. In view I can do %=l
 @schedule.start_date %.

 Can you tell me how I can do that with #{start_date}? The format I
 need is dd.mm.yyy

Have you tried #{l start_date}
The #{ } syntax in a double quoted string just says drop into ruby and
work out the expression between the braces.
Alternatively if you always want the same format you can use
#{start_date.strftime(some parameters to format it the way you want)}

Colin


 Regards
 Arwed


 On 20 Sep., 21:46, Colin Law clan...@googlemail.com wrote:
 2009/9/20 arwed a...@bbp.biz:



  Hi,

  I have a model with start_date and end_date and a helper:

  def period
   #{start_date} - #{end_date}

 If you want the dates to appear as localised strings you must do it
 here.  Formatting them as appropriate as you build the string.  If I
 understand the question correctly.

 Colin

  end

  in my view I have:

  %= f.collection_select :schedule_id,
  @convention.schedules, :id, :period, {:selected = @schedule.id} %

  How can I show :period localized, as %=l ... won't work.

  Regards
  Arwed


 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] A security related question

2009-09-20 Thread comopasta Gr

Hi,

I'm running restful_authentication plugin on my projects.
When we login to the app the contents for the form that the login sends
are clearly available for anyone sniffing traffic. For example locally I
can see that the form sends:

authenticity_token=TEzCRYvzJbioHD3rpt3VuWHkl4rmrngRn3V%2BjCM9qz4%3Dlogin=user1password=pass1mobile=falsecommit=Log+In

So the username and password can be seen there.

I know https would hide that, also the token is needed for anyone to use
those credentials later.

But, how can this be considered secure?
This is not directly related to restful_authentication plugin, common
issue with any other forms.

Cheers.
-- 
Posted via http://www.ruby-forum.com/.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: render :partial = @object

2009-09-20 Thread Conrad Taylor
Hi, what version of Rails is being defined within the environment.rb file?

-Conrad

On Sun, Sep 20, 2009 at 10:27 AM, Eric ericgh...@gmail.com wrote:


 Is there something I'm not getting here? The short form should be
 either

 render :partial = @foo

 -or-

 render @foo

 I've never seen render :partial @foo

 -eric


 On Sep 19, 9:44 pm, Me chabg...@gmail.com wrote:
  Running rails  2.1.0 when I do this:
 
  %= render :partial = 'style', :collection = @styles %
 
  I get the collection fine in my index file.  When I try the shortcut:
 
  %= render :partial  @styles %
 
  I get this error:
 
  Couldn't find template file for active_record/named_scope/scopes/
  _scope
 
  Any ideas??
 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: rails CMS - which is most stable simplest at the momen

2009-09-20 Thread Marnen Laibow-Koser

Mohit Sindhwani wrote:
 Greg Hauptmann wrote:
 Hi - there quite a few Ruby on Rails CMS's out there.  Can anyone give
 a picture of which are the most supported/worked on at the moment
 (i.e. most likely to have a long life)?   Just after a simple CMS...
   
 radiant - www.radiantcms.org

Radiant is probably the best known. AdvaCMS looks quite promising, but 
seems a bit immature at the moment.  There's also BrowserCMS, about 
which I know little.
 
 Cheers,
 Mohit.
 9/21/2009 | 1:25 AM.

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org
-- 
Posted via http://www.ruby-forum.com/.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: How to: redirect_to through a folder hierarchy (upwards)

2009-09-20 Thread Tom Ha

Anyone...?
-- 
Posted via http://www.ruby-forum.com/.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: render :partial = @object

2009-09-20 Thread Chris Habgood
2.1.0

On Sun, Sep 20, 2009 at 4:00 PM, Conrad Taylor conra...@gmail.com wrote:

 Hi, what version of Rails is being defined within the environment.rb file?

 -Conrad

 On Sun, Sep 20, 2009 at 10:27 AM, Eric ericgh...@gmail.com wrote:


 Is there something I'm not getting here? The short form should be
 either

 render :partial = @foo

 -or-

 render @foo

 I've never seen render :partial @foo

 -eric


 On Sep 19, 9:44 pm, Me chabg...@gmail.com wrote:
  Running rails  2.1.0 when I do this:
 
  %= render :partial = 'style', :collection = @styles %
 
  I get the collection fine in my index file.  When I try the shortcut:
 
  %= render :partial  @styles %
 
  I get this error:
 
  Couldn't find template file for active_record/named_scope/scopes/
  _scope
 
  Any ideas??



 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] current best approach for Sending Files (streaming files e.g. images) in rails???

2009-09-20 Thread Greg Hauptmann

Hi,

Q1 - What's the current most popular approach (plugin/gem or
otherwise) for sending files / streaming files (e.g. images) back to a
browser?

Q2 - Noting I'm on Dreamhost.com on a shared environment (so don't get
much access to Apache), I was going to stick the images in mysql.
Should keep things simple.  Later if the service really gets used or
response times are an issue I could change this approach (store them
in a directory I create in the Rails app, but not under /public I
guess).  This should be OK no?   Again I'm not sure how much access to
Apache with Dreamhost.com shared platform I would have and whether
there would be a well known more performant option here.
http://wiki.dreamhost.com/Apache


Background - So the main page would be referencing these images via a
Rails controller to ensure authentication occurs.  So it's the
standard scenario of allowing a user to upload files/images, but when
they download them how to serve this back to them in an efficient
fashion.

Tks

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: render :partial = @object

2009-09-20 Thread Conrad Taylor
Hi,
if you're using Rails 2.1.0 or earlier, you'll need to use the following
syntax:

a)  render :partial = partial_name, :collection = @collections

 Note:  The above requires the partial, _partial_name.html.erb.

b)  render :partial = partial_name, :object = @object

 Note:  The above requires the partial, _partial_name.html.erb.

If you're using Rails 2.2.2 or greater, then you can use the following
syntax:

a)  render :partial = @collections

 Note:  The above uses the partial, _collection.html.erb.

b)  render :partial = @object

 Note:  The above used the partial, _object.html.erb.

Good luck,

-Conrad




On Sun, Sep 20, 2009 at 2:07 PM, Chris Habgood chabg...@gmail.com wrote:

 2.1.0


 On Sun, Sep 20, 2009 at 4:00 PM, Conrad Taylor conra...@gmail.com wrote:

 Hi, what version of Rails is being defined within the environment.rb file?

 -Conrad

 On Sun, Sep 20, 2009 at 10:27 AM, Eric ericgh...@gmail.com wrote:


 Is there something I'm not getting here? The short form should be
 either

 render :partial = @foo

 -or-

 render @foo

 I've never seen render :partial @foo

 -eric


 On Sep 19, 9:44 pm, Me chabg...@gmail.com wrote:
  Running rails  2.1.0 when I do this:
 
  %= render :partial = 'style', :collection = @styles %
 
  I get the collection fine in my index file.  When I try the shortcut:
 
  %= render :partial  @styles %
 
  I get this error:
 
  Couldn't find template file for active_record/named_scope/scopes/
  _scope
 
  Any ideas??






 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] [Authlogic]

2009-09-20 Thread Lb2007

After I upgraded my Authlogic to 2.1.2 I'm facing an odd error when
trying to use my webpage; it comes up with an error 'undefined method
`^' for e:String'. I've double checked the lines in the Authlogic
code (see codepad urls for the tracelog), but I can find no trace of
any ^  in the code anywhere. The methods that result in this error
are the default current_user(_session) methods from the Authlogic
docs.

I'm not sure if this is a bug in Authlogic or my code, but I'd love to
know the answer to that!

Passenger output (and called methods): http://codepad.org/lm43n9KN
WEBrick output (bigger tracelog): http://codepad.org/owmJoGMx

Thanks in advance.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: [Authlogic]

2009-09-20 Thread Yorick
I forgot to mention; this is on Ruby 1.9.1 with Rails 2.3.4, the error is
not appearing on my Windows devbox with Ruby 1.8 and Rails 2.3.3, which is
making it rather odd. Downgrading Authlogic does not prove to be a solution
either, so it's likely unrelated. I also note that I forgot to add a subject
after the tag, I'm very sorry, I'm chaotic today.

On Sun, Sep 20, 2009 at 11:31 PM, Lb2007 yor...@gmail.com wrote:

 After I upgraded my Authlogic to 2.1.2 I'm facing an odd error when
 trying to use my webpage; it comes up with an error 'undefined method
 `^' for e:String'. I've double checked the lines in the Authlogic
 code (see codepad urls for the tracelog), but I can find no trace of
 any ^  in the code anywhere. The methods that result in this error
 are the default current_user(_session) methods from the Authlogic
 docs.

 I'm not sure if this is a bug in Authlogic or my code, but I'd love to
 know the answer to that!

 Passenger output (and called methods): http://codepad.org/lm43n9KN
 WEBrick output (bigger tracelog): http://codepad.org/owmJoGMx

 Thanks in advance.




-- 
Yorick

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] What's the Right Rails Prologue for a Standalone Program

2009-09-20 Thread ddoherty03

I am trying to write a small program to exercise certain of my Rails
classes without having to go through a browser.

I have a file that like this:
### filer_convert.rb #
require File.dirname(__FILE__) + '/../../config/boot'
require 'filer'

Filer.convert(10)

#

I want to use it to debug the Filer.convert method inside an IDE
(Komodo).  filer.rb could be simply this:

 filer.rb ###
class Filer  ActiveRecord::Base
end
#

I was hoping that the prelude to this file, the first two require
statements would be enough to allow me to
test rails classes.  When I debug this, though, I get the error
something like undefined constant Active Record.  I suspect there is
more that I need in the prelude to filer_convert.rb to get the whole
panopoly of rails functionality, but can't figure out what it is.

What should be 'required' at the beginning of filer_convert.rb to
bring in all of rails?

Thank.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: How to: redirect_to through a folder hierarchy (upwards)

2009-09-20 Thread Vamsi krishna Kilari

Tom,

You should be able to do like this.

redirect_to :controller = /members, :action = 'show'

Thanks,
Kilari.
http://kilari.co.in
-- 
Posted via http://www.ruby-forum.com/.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Really stuck on nested resources

2009-09-20 Thread AGoofin

One other way to think about this - you shouldn't need to nest
resources more then one level deep.

You only deal with children in relation to parents and dogs in
relation to children. Separate relationships which can be handled
transparently. Plus the links you have to generate get a lot more
confusing - parents_childrens_dog_path( parent_id, child_id, dog_id)
or some such...

On Sep 20, 1:41 pm, mlittle mdlit...@gmail.com wrote:
 MichaelB:

 THANK YOU! So much. Your solution fixed my problem and taught me a
 bunch about rails.

 Thanks again for your help.

 On Sep 20, 8:32 am, MichaelB michael.james.bamf...@gmail.com wrote:

  Hey mlttle-

  You can create a new dog with:

  def create
    @dog = Parent.find(params[:parent_id]).children.find(params
  [:child_id]).dogs.create
  end

  The console is your best friend to quickly diagnose errors:

   @record= parent.child.dog.build(params[:dog])

  NoMethodError: undefined method `child' for #Parent:0x22b6748

  .. becuase your parent model has many **children**

   @record= parent.children.find(child).dogs.build(params[:dog])

  Michael
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: is there a ruby on rails framework/app that would be a good starting point for these requirements???

2009-09-20 Thread AGoofin

Sounds like a cms app for which there was a recent post on the list
for.

 Radiant is probably the best known. AdvaCMS looks quite promising, but
 seems a bit immature at the moment.  There's also BrowserCMS

One that I like is Wagn: http://www.wagn.org/wagn/Introduction

It has a unique card like approach to cms.

Does sound like a project you might be able to build yourself - I
don't know if any of the cms's mentioned will let you serve uploaded
html pages. But you might be able to extend one to do it.


On Sep 20, 3:29 am, Greg Hauptmann greg.hauptmann.r...@gmail.com
wrote:
 Hi,

 Just wondering whether there is an existing open source Ruby on Rails
 app that would be a good starting point for doing this:

 * want a backend web application/service that has an API to allow a
 desktop client application to programmatically upload complete web
 pages (HTML  images that the HTML links to) to be hosted
 * the web application API would have to support (a) create account for
 new user, (b) upload / modify / delete web pages for specified user
 * part of creating the account for user would be to set them up with a
 username/password, as the content needs to be private (user will need
 username/password to access)
 * so each of the accounts (setup with a user password) are all
 separate with no linkages - it's just a service that will allow
 multiple users to have their own HTML/images hosted, and the point
 being that they won't manually set this up themselves, but rather the
 clientside application will have the smarts to do this, therefore
 requires the back-end web application/service to provide the API

 Any existing open source apps sound like they might fit these
 requirements, RoR blog app, or RoR Wiki app or something?  (but it
 needs the programmatic APIs)

 I guess the fallback for me would be to develop a website from the
 ground up to do this (e.g. Ruby on Rails), but it would be nice to
 have something as a starting point.

 Thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Finding elements with hpricot/nokogiri

2009-09-20 Thread David

I am attempting to parse a wiktionary entry to retrieve all english
definitions.  I am able to retrive all definitions, the problem is
that some definitions are in other languages.  What I would like to do
is somehow retrieve only the html block with english definitions.  I
have found that, in the case that there are other language entries,
the header after the english definitions can be retrieved with: header
= (doc/h2)[3].  So I would like to only search all the elements
before this header element.  I thought that may be possible with
header.preceding_siblings(), but that does not seem to be working.
Any suggestions?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Really stuck on nested resources

2009-09-20 Thread mlittle

Agoofin:

The only reason I am doing it this way is for the current_user. This
is the only way I know how to make sure another user does not see a
record created by someone else. If I knew another way to do this then
I would avoid the nested resources. I can see where my current model
is going to become a pain to manage. If I knew how to do that I would
change my ways. Currently I do:

current_user.children.find(child).dogs.build(params[:dog])

I know there has to be a better way but I am glad it's working now. I
am new and am sure as I improve I will discover the appropriate way to
handle this.

Thanks for the feedback.

On Sep 20, 5:32 pm, AGoofin amor...@gmail.com wrote:
 One other way to think about this - you shouldn't need to nest
 resources more then one level deep.

 You only deal with children in relation to parents and dogs in
 relation to children. Separate relationships which can be handled
 transparently. Plus the links you have to generate get a lot more
 confusing - parents_childrens_dog_path( parent_id, child_id, dog_id)
 or some such...

 On Sep 20, 1:41 pm, mlittle mdlit...@gmail.com wrote:

  MichaelB:

  THANK YOU! So much. Your solution fixed my problem and taught me a
  bunch about rails.

  Thanks again for your help.

  On Sep 20, 8:32 am, MichaelB michael.james.bamf...@gmail.com wrote:

   Hey mlttle-

   You can create a new dog with:

   def create
     @dog = Parent.find(params[:parent_id]).children.find(params
   [:child_id]).dogs.create
   end

   The console is your best friend to quickly diagnose errors:

@record= parent.child.dog.build(params[:dog])

   NoMethodError: undefined method `child' for #Parent:0x22b6748

   .. becuase your parent model has many **children**

@record= parent.children.find(child).dogs.build(params[:dog])

   Michael
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: What's the Right Rails Prologue for a Standalone Program

2009-09-20 Thread pharrington

On Sep 20, 3:55 pm, ddoherty03 ddohert...@gmail.com wrote:
 I am trying to write a small program to exercise certain of my Rails
 classes without having to go through a browser.

 I have a file that like this:
 ### filer_convert.rb #
 require File.dirname(__FILE__) + '/../../config/boot'
 require 'filer'

 Filer.convert(10)

 #

 I want to use it to debug the Filer.convert method inside an IDE
 (Komodo).  filer.rb could be simply this:

  filer.rb ###
 class Filer  ActiveRecord::Base
 end
 #

 I was hoping that the prelude to this file, the first two require
 statements would be enough to allow me to
 test rails classes.  When I debug this, though, I get the error
 something like undefined constant Active Record.  I suspect there is
 more that I need in the prelude to filer_convert.rb to get the whole
 panopoly of rails functionality, but can't figure out what it is.

 What should be 'required' at the beginning of filer_convert.rb to
 bring in all of rails?

 Thank.

You need to include environment.rb, not boot.rb (boot.rb will load
Rails itself, but not much actually happens without a defined Rails
environmen).
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: for crontab

2009-09-20 Thread Preksha Patel

Hassan Schroeder wrote:
 On Sat, Sep 19, 2009 at 12:33 AM, Preksha Patel
 rails-mailing-l...@andreas-s.net wrote:
 
 so i want to use cron in ruby on rails application. in application i
 want to fire some query everyday so where i should write the code for
 query so that when cron is run that query is also fire??
 
 Cron runs whatever you tell it too, wherever that is. :-)
 
 If you want to run something with the Rails app's environment, you
 probably want to add the code to {RAILS_ROOT}/lib and invoke it
 via {RAILS_ROOT}/script/runner
 
 HTH!
 --
 Hassan Schroeder  hassan.schroe...@gmail.com
 twitter: @hassan

hi,
as you told to add the code to {RAILS_ROOT}/lib so you mean to say to 
add the code in lib folder, i have to make one file with extension is 
what?? and {RAILS_ROOT}/script/runner is the command which i should 
run??
i haven't used corn before so can you please tell me something in 
detail??

thanks,
Preksha..
-- 
Posted via http://www.ruby-forum.com/.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Installing RedCloth

2009-09-20 Thread Davo

Hi All,

I'm working through a book which touches on Textile for formating in
the body of a blog.

The procedure is:

1)  Add this line to environment.rb
config.gem RedCloth, :version = = 3.301, :source = http://
code.whytheluckystiff.net

2)  rake gems:install

3)  use   %= textilize(article.body) %

So it fails at #1 because of the whythluckystiff resources not being
available anymore !

So does anyone have an alternative so I can get this working ?

regards, Dave Porter


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Doubly-nested models

2009-09-20 Thread John Woods

Hi all,

I have three models, like so:

User
belongs_to :person
accepts_nested_attributes_for :person, :allow_destroy = false
has_many :contacts

Person
has_many :contacts
accepts_nested_attributes_for :contacts, :allow_destroy = true

Contact
belongs_to :person

And actually, it's a bit more complicated because Contact uses single-
table polymorphism and may be a PhoneNumber or an Address. Different
information would be filled in for each on the form, so right now I
have separate partials for each of those.

My goal is to create both the User and the Person, as well as a
Contact (if specified), when the first form is submitted. I've got it
so it creates the User and the Person, but it doesn't set any of the
data in the Person row. It won't create any Contacts at all.


# new.html.erb
h1Sign up/h1

% form_for @user, :url = account_path do |f| %
  %= f.error_messages %
  %= render :partial = form, :object = f %
  p
%= f.submit Register %
  /p
% end %

# _form.html.erb
%= error_messages_for :user %
div class=user
  % form_for @user do |user_form| -%

%= user_form.label :email %br /
%= user_form.text_field :email %br /
br /
%= user_form.label :password, user_form.object.new_record? ?
nil : Change password %br /
%= user_form.password_field :password %br /
br /
%= user_form.label :password_confirmation, 'Confirm' %br /
%= user_form.password_field :password_confirmation %br /
br /
%= render :partial = person, :object = @person %
  % end -%
/div
br /

# _person.html.erb
div class=person
  % form_for @person do |person_form| -%

%= person_form.label :title %br /
%= person_form.text_field :title %br /
br /
%= person_form.label :first_name %br /
%= person_form.text_field :first_name %br /
br /
%= person_form.label :last_name %br /
%= person_form.text_field :last_name %br /
br /
%= person_form.label :job_title %br /
%= person_form.text_field :job_title %br /
br /
div id=contacts
  %= render :partial = address,  :collection =
@person.addresses %
  %= render :partial = phone_number, :collection =
@person.phone_numbers %
/div
p
  %= add_contact_link :address %
  %= add_contact_link :phone_number %
/p
  % end -%
/div

# _phone_number.html.erb (_address is very similar)
div class=phone_number
  % new_or_existing = phone_number.new_record? ? 'new' : 'existing'
%
  % prefix = person[#{new_or_existing}_contact_attributes][] %

  % fields_for prefix, phone_number do |contact_form| -%
p
  %= contact_form.hidden_field :type %
  Area + Phone %= contact_form.text_field :value %br/
  %= remove_contact_link :phone_number, 'remove' %
/p
  % end -%
/div

# users_controller.rb
  def new
@user = User.new
@person = @user.build_person
@addresses = @person.addresses.build
@phone_numbers = @person.phone_numbers.build
  end

  # POST /users
  # POST /users.xml
  def create
@user = User.new(params[:user])
if @user.save
  flash[:notice] = 'User was successfully registered.'
  redirect_back_or_default account_url
else
  render :action = :new
end
  end


Any thoughts? Apologies if things are a little unorthodox. I've been
fiddling for hours.

Thanks,
John
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: What's the Right Rails Prologue for a Standalone Program

2009-09-20 Thread ddoherty03

Thanks, pharrinton.  That did it.  I still get a strange internal
error message when I run it under komodo, but I assume that's
a komodo issue.

On Sep 20, 10:33 pm, pharrington xenogene...@gmail.com wrote:
 On Sep 20, 3:55 pm, ddoherty03 ddohert...@gmail.com wrote:



  I am trying to write a small program to exercise certain of my Rails
  classes without having to go through a browser.

  I have a file that like this:
  ### filer_convert.rb #
  require File.dirname(__FILE__) + '/../../config/boot'
  require 'filer'

  Filer.convert(10)

  #

  I want to use it to debug the Filer.convert method inside an IDE
  (Komodo).  filer.rb could be simply this:

   filer.rb ###
  class Filer  ActiveRecord::Base
  end
  #

  I was hoping that the prelude to this file, the first two require
  statements would be enough to allow me to
  test rails classes.  When I debug this, though, I get the error
  something like undefined constant Active Record.  I suspect there is
  more that I need in the prelude to filer_convert.rb to get the whole
  panopoly of rails functionality, but can't figure out what it is.

  What should be 'required' at the beginning of filer_convert.rb to
  bring in all of rails?

  Thank.

 You need to include environment.rb, not boot.rb (boot.rb will load
 Rails itself, but not much actually happens without a defined Rails
 environmen).
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Installing RedCloth

2009-09-20 Thread Dave Porter

OK, I got RedCloth installed, but line at step 3 now gives this error:
(I replaced my original %= textilize(article.body) %  with the line
shown from the rail api, they both give the same error! )
Regards, Dave


NameError in Articles#index

Showing app/views/articles/index.html.erb where line #7 raised:

uninitialized constant ActionView::Helpers::TextHelper::RedCloth
Extracted source (around line #7):

4:   h2%= link_to h(article.title), article %/h2
5:
6:   div  class=column span-6
7: %= textilize(*This is Textile!*  Rejoice!) %
8:   !-- /column --
9:   /div
10:
RAILS_ROOT: C:/Ruby/RailsApps/blog

Application Trace | Framework Trace | Full Trace
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/
dependencies.rb:440:in `load_missing_constant'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/
dependencies.rb:80:in `const_missing'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_view/
helpers/text_helper.rb:251:in `textilize'
C:/Ruby/RailsApps/blog/app/views/articles/index.html.erb:7:in
`_run_erb_app47views47articles47index46html46erb'
C:/Ruby/RailsApps/blog/app/views/articles/index.html.erb:1:in `each'
C:/Ruby/RailsApps/blog/app/views/articles/index.html.erb:1:in
`_run_erb_app47views47articles47index46html46erb'
C:/Ruby/RailsApps/blog/app/controllers/articles_controller.rb:7:in
`index'


On Sep 21, 11:57 am, Davo dave.southpe...@gmail.com wrote:
 Hi All,

 I'm working through a book which touches on Textile for formating in
 the body of a blog.

 The procedure is:

 1)  Add this line to environment.rb
 config.gem RedCloth, :version = = 3.301, :source = http://
 code.whytheluckystiff.net

 2)  rake gems:install

 3)  use   %= textilize(article.body) %

 So it fails at #1 because of the whythluckystiff resources not being
 available anymore !

 So does anyone have an alternative so I can get this working ?

 regards, Dave Porter
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: How to get value from link_to_remote's :with paramenter?

2009-09-20 Thread Sijo Kg

Hi Is it solved? Once more try exact this Cannot see anyother error.

link_to_remote Apply, :update = result, :url = {:action = 
discount_code}, :with = 'discount='+$('discount_code').value

And in controller  params[:discount]



Sijo
-- 
Posted via http://www.ruby-forum.com/.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: How to get value from link_to_remote's :with paramenter?

2009-09-20 Thread Vikas Gholap

Quy Doan wrote:
 sorry it's :
:with='discount='+$('discount_code').value .
 You missed single quote in discount_code  :)
 
 On Sep 19, 10:46�am, Vikas Gholap rails-mailing-l...@andreas-s.net

Thanks,

but how can i pass multiple parameters through :with option in 
link_to_remote

for example

=link_to_remote Apply, :update = plan_discount, :url = { :action 
= discount_code}, :with='discount='+$('discount_code').value 
'discount2='+$('discount_code2').value

This is not working.

Where I'm doing wrong.
-- 
Posted via http://www.ruby-forum.com/.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: How to get value from link_to_remote's :with paramenter?

2009-09-20 Thread Sijo Kg

Hi Vikas

:with ='discount='+ escape($('discount_code').value) + 'discount2=' + 
escape($('discount_code2').value)



Sijo
-- 
Posted via http://www.ruby-forum.com/.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] `observer' for AccountController:Class

2009-09-20 Thread fireflyman

hi, I've just changed to rails 2.0 and got undefined method
`observer' for AccountController:Class
 What can i do for this problem?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: `observer' for AccountController:Class

2009-09-20 Thread fireflyman

This example come from Beginning Ruby on Rails E-Commerce

On Sep 21, 1:19 pm, fireflyman yangxiwenh...@gmail.com wrote:
 hi, I've just changed to rails 2.0 and got undefined method
 `observer' for AccountController:Class
  What can i do for this problem?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: for crontab

2009-09-20 Thread Hassan Schroeder

On Sun, Sep 20, 2009 at 8:56 PM, Preksha Patel
rails-mailing-l...@andreas-s.net wrote:

 as you told to add the code to {RAILS_ROOT}/lib so you mean to say to
 add the code in lib folder, i have to make one file with extension is
 what?? and {RAILS_ROOT}/script/runner is the command which i should
 run??

~/projects/example$ more lib/whatever.rb
class Whatever
  class  self
def say_it
  puts it, that's all
end
  end
end
~/projects/example$ script/runner Whatever.say_it
it, that's all
~/projects/example$

 i haven't used corn before so can you please tell me something in
 detail??

Have you read the man pages for cron and crontab? That should be
enough examples to get you started, I'd think. :-)

-- 
Hassan Schroeder  hassan.schroe...@gmail.com
twitter: @hassan

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: for crontab

2009-09-20 Thread Sijo Kg

Hi Preksha
   Read this

http://railsenvy.com/2007/6/11/ruby-on-rails-rake-tutorial




Sijo
-- 
Posted via http://www.ruby-forum.com/.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---