Re: [Rails] Re: Re: STI and nested object on subclass

2010-09-13 Thread Javier Ruiz
Hi Daniel

Thanks for helping :-)

This is exactly how I was thinking it should work. But I just tried
using set_table_name and I still got the same result, for example, using
your code (which is exactly what I'd love to do), I get this:

w = Worker.create(:name => "WorkerName") # ok
p = Person.create(:name => "PersonName") # ok
ac = AnotherClass.create # ok

ac.worker = w # here i got the error! like:
# ActiveRecord::StatementInvalid: Mysql::Error: Unknown column
'person.another_class_id' in 'where clause': SELECT * FROM `person`
WHERE (`person`.another_class_id = 1)  LIMIT 1

It still goes to the parent class to search for the relational id.
"set_table_name" works for you in this particular case? could it be the
activerecord version I use? My gems are:

actionmailer (2.3.9)
actionpack (2.3.9)
activerecord (2.3.9)
activeresource (2.3.9)
activesupport (2.3.9)
builder (2.1.2)
capistrano (2.5.19)
highline (1.6.1)
i18n (0.4.1, 0.3.7)
json (1.4.6)
json_pure (1.4.6)
multi_json (0.0.4)
mysql (2.8.1)
net-scp (1.0.3)
net-sftp (2.0.5)
net-ssh (2.0.23)
net-ssh-gateway (1.0.1)
pg (0.9.0)
racc (1.4.6)
rack (1.1.0)
rails (2.3.9)
rake (0.8.7)
rspec (1.3.0)
text-format (1.0.0)
text-hyphen (1.0.0)
tmail (1.2.7.1)
tzinfo (0.3.23)
will_paginate (2.3.14)


And the trace when I get the error:

from 
/usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.9/lib/active_record/connection_adapters/abstract_adapter.rb:227:in
 `log'

from 
/usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.9/lib/active_record/connection_adapters/mysql_adapter.rb:324:in
 `execute'

from 
/usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.9/lib/active_record/connection_adapters/mysql_adapter.rb:639:in
 `select'

from 
/usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.9/lib/active_record/connection_adapters/abstract/database_statements.rb:7:in
 `select_all_without_query_cache'

from 
/usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.9/lib/active_record/connection_adapters/abstract/query_cache.rb:62:in
 `select_all'

from 
/usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.9/lib/active_record/base.rb:665:in
 `find_by_sql'

from 
/usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.9/lib/active_record/base.rb:1582:in
 `find_every'

from 
/usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.9/lib/active_record/base.rb:1539:in
 `find_initial'

from 
/usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.9/lib/active_record/base.rb:617:in
 `find'

from 
/usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.9/lib/active_record/associations/has_one_association.rb:81:in
 `find_target'

from 
/usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.9/lib/active_record/associations/association_proxy.rb:236:in
 `load_target'

from 
/usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.9/lib/active_record/associations/association_proxy.rb:113:in
 `reload'

from 
/usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.9/lib/active_record/associations.rb:1256:in
 `worker'
from (irb):2

Regards,

Javi Ruiz

 

On Mon, 2010-09-13 at 14:30 -0500, Daniel Gaytán wrote:
> Hello  Javier,
> 
> I was just checking the set_table_name class method of ActiveRecord
> and I think that could work for you:
> 
> class AnotherClass < ActiveRecord::Base
>   has_one :worker
> end
> 
> class Person < ActiveRecord::Base
>   def something
> self.name
>   end
> end
> 
> class Worker < Person
>   set_table_name "workers"
> end
> 
> w = Worker.create(:name => "WorkerName")
> p = Person.create(:name => "PersonName")
> ac = AnotherClass.create
> 
> ac.worker = w
> ac.save
> 
> ac.worker.something # => "WorkerName"
> 
> 
> I hope that would be helpful
> 
> Daniel Gaytán
> 
> 2010/9/13 Marnen Laibow-Koser 
> [Please quote when replying.  Otherwise the discussion is
> impossible to
> follow.]
> 
> Javier Ruiz wrote:
> > Yep that's finally how I will have to do it... but this is
> not what I
> > wanted. A has_one relation means that I have to access
> things like:
> >
> > Anotherclass.property
> > Anotherclass.childclass.specific_property
> > Anotherclass.childclass.parentclass.common_property
> 
> 
> That makes sense from a relational point of view.  If you
> don't like it,
> then use STI.
> 
> >
> > And more important... I need to manually manage related
> objects (or
> > create hooks os similar). I mean I need for example to do
> something
> > like:
> >
> > a = Anotherclass.new
> > b = Childclass.new
> > a.childclass = b
> >
> > ... and so on...
> 
> 
> You'd need to do that regardless of whether your original idea
> worked.
> 
> >
> > I was thinking "rails' magic" was really magic ;-)
> 
> 
> I suppose it is, but it doesn't extend to spreading one class
> across
> multiple tables.
> 
> If you were ambitiou

[Rails] Re: View and Controllers association

2010-09-13 Thread Awijeet Mr.
radhames brito wrote:
> Post (singular with capital) is the model

that's true, but here instead of Post.module, i.module is called.
and to know it's class when i put i.class it said Post, and in 
app/models/post.rb

no module function is there.. :(
-- 
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-t...@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: View and Controllers association

2010-09-13 Thread Awijeet Mr.
Felix Schäfer wrote:
> Am 13.09.2010 um 14:58 schrieb Awijeet Mr.:
> 
>> if  I write i.class it returns Post, so I thought module will be a
>> method in post_controller.rb. But it's not
> 
> If i is of the type Post, i.module will call the method module from the 
> Post object in app/models/post.rb, not from a PostsController object as 
> you seem to think it will.
> 
> Felix

I have checked the code in app/models/post.rb
there are no module method, but at lot of space self.module function has 
been called, and a defined method is def set_module
-- 
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-t...@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] pdf.table

2010-09-13 Thread Jeffrey Bonson
Hi,
 i have a table inside Prawn file like

   grandtot...@sql_query.size
total=[""],[""]
pdf.table total,
:width => 768,
:headers => ["Grand Total : #{grandtotal} "],
:header_color => 'e5e5e5',
:border_style => :underline_header

there are other data above them. what happens is, when the grandtotal
prints on the last line of a page,(in some cases only), they are
printing it twice ..like, on the last line on page 1 and first line of
page 2.
Is it any property of pdf.table to print it on the next line ALSO, if
there is not much space on the previous page?


please advice
~Jeff
-- 
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-t...@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] Roles that are User<>Project Based

2010-09-13 Thread nobosh
Hello... Currently I'm using Devise & CanCan which allows me to create
Users with Roles using a (Roles_Users) table.

That's nice, but what I want is to Have Projects in my app and for
each project for a user to possibly have a role like (Admin, Viewer,
etc)

What kind of Model would work for this?

Models
Users
 has_many: projects

Projects
?

Roles
?

Users_Roles_Projects (user_id, project_id, role_id)


What do you think? I'm a newbie and could use the understanding and
thinking from you fine experienced folks. 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-t...@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.



Re: [Rails] req: Method executed in link_to

2010-09-13 Thread Srikanth Shreenivas
Reference on link_to here:
http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to

:method is used for specifying HTTP method such as POST, GET, etc.

The parameter that you are passing (method_to_run) is not a valid value for
:method.

I suggest you define a controller and invoke one of its methods through the
link.

Example:
link_to "Feature", :controller => "mycontroller", :action => "method_to_run"




On Tue, Sep 14, 2010 at 9:29 AM, Jason N  wrote:

> Group,
>
> This might very well be Rails 102 stuff, but it's doing my little head
> in.
>
> Simple request - I want to create a link within my View to fire off a
> system call to run an external program.
>
> In this example it's pretty easy - run a Windows system command that
> simply starts something (it's not what I'm trying to achieve but it's
> an easy debug method):
>
>  def method_to_run
>system('start dir > test.txt')
>  end
>
> How the *heck* do I link to this method within my View?
>
> A simple <%= link_to feature, :method => method_to_run %> results in
> the following error:
>
> 
> undefined local variable or method `method_to_run' for #<# 0x46c3248>:0x46c1808>
> 
>
>
> Jason
>
> --
> 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-t...@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.
>
>

-- 
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-t...@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.



Re: [Rails] Re: Re: Re: Re: Authlogic Rails 3

2010-09-13 Thread Jeffrey L. Taylor
Quoting Paul Mr :
> Paul Mr wrote:
> > Rick R wrote:
> >> On Sun, Sep 12, 2010 at 10:14 PM, Paul Mr  wrote:
> > 
> > thats what Im betting on.
> 
> Pretty much.. that one creates all the models/scaffolds/controllers the 
> usual way...not even caring about Authlogic::Session::Base
> 
> though I assume possibly, manually editing the one item to reflect that 
> instead of activerecord (or whatever it was).
> -- 

IIRC, AuthLogic works w/ Rails 3, but doesn't have the new generator
structure.  Generate it in Rail 2.x and copy the files over.

Jeffrey

-- 
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-t...@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] req: Method executed in link_to

2010-09-13 Thread Jason N
Group,

This might very well be Rails 102 stuff, but it's doing my little head
in.

Simple request - I want to create a link within my View to fire off a
system call to run an external program.

In this example it's pretty easy - run a Windows system command that
simply starts something (it's not what I'm trying to achieve but it's
an easy debug method):

  def method_to_run
system('start dir > test.txt')
  end

How the *heck* do I link to this method within my View?

A simple <%= link_to feature, :method => method_to_run %> results in
the following error:


undefined local variable or method `method_to_run' for #<#:0x46c1808>



Jason

-- 
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-t...@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: Deprecation warning with form_tag

2010-09-13 Thread rodrigo3n
Thanks!

On Sep 13, 7:48 pm, radhames brito  wrote:
> watch this
>
> http://railscasts.com/episodes/208-erb-blocks-in-rails-3
>
>
>
> On Mon, Sep 13, 2010 at 4:09 PM, rodrigo3n  wrote:
> > Thanks for the reply but this didn't work. Instead, I wrote this:
>
> > <%= form_tag '/sessions' do -%>
> >   <%= image_submit_tag 'login.png', :class => 'login' %>
> > <% end -%>
>
> > And it works and the deprecation method is gone.
>
> > Thanks!
>
> > On Sep 13, 3:53 pm, Greg Donald  wrote:
> > > On Mon, Sep 13, 2010 at 1:47 PM, rodrigo3n  wrote:
> > > > Hello everyone, I am using Rails 3 and receiving an deprecation
> > > > warning when running the specs of my app. The warning:
>
> > > > ..*F.DEPRECATION WARNING: <% %> style block helpers are
> > > > deprecated. Please use <%= %>. (called from
> > > > <% form_tag 'sessions' do %>
>
> > > <%= form_tag do %>
>
> > > <% end %>
>
> > > --
> > > Greg Donald
> > > destiney.com | gregdonald.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-t...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > rubyonrails-talk+unsubscr...@googlegroups.com > e...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/rubyonrails-talk?hl=en.

-- 
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-t...@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: Problems with the money gem

2010-09-13 Thread Marnen Laibow-Koser
Jon Seidel wrote:
> I've done all that;

Done all what?  You failed to quote what you were referring to.

> but since this is an ActiveRecord object, I was
> hoping there was a way to do this in one spot,

There is.  Use the constructor as I already suggested.  Do you not know 
how to do this?

> through a Rails hook,
> rather than having to remember to code this each time.

Right.  That's what constructors do.

> 
> The way I encapsulated all this was to create an initialize_to_zeros
> method and now I call that each time after doing a model.new

Unnecessary.  Just put that in the constructor.

> 
> ...jon
-- 
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-t...@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: Paperclip - helppppp

2010-09-13 Thread Agoofin
If you're getting the original image then you have ImageMagic setup
correctly.

On Windows there is a bug in the current paperclip gem where the
ImageMagick arguments are surrounded by single quotes, which windows
doesn't like.

Take a look at the console output to see the errors, try the commands
that paperclip log outputs. If you have the single quote problem then
update the paperclip.rb file:
def quote_command_options(*options)
  options.map do |option|
option.split("'").map{|m| "#{m}" }.join("\\'") #removed single
quotes around #{m}
  end

Also note that in current version of ImageMagic the size in the styles
hash no longer takes a final character, only the dimensions. So if you
have :medium =>'300x300>', it now has to be just '300x300'

Hope this helps

On Sep 13, 8:44 pm, daze  wrote:
> I keep seeing this error when I try to upload an image:
> --
> 2 errors prohibited this panel from being saved
>
> There were problems with the following fields:
>
> Image C:/Users/Family/AppData/Local/Temp/stream,10032,0.png is not
> recognized by the 'identify' command.
> Image C:/Users/Family/AppData/Local/Temp/stream,10032,0.png is not
> recognized by the 'identify' command.
> --
>
> If I have my model Panel (which needs an image attachment) look like
> this, with the 'whiny' option set to false...
>
> class Panel < ActiveRecord::Base
>         belongs_to :section
>         acts_as_list
>
>         has_attached_file :image, :styles => { :medium => "300x300>",:thumb
> => "100x100>" }, :whiny => false
>
>         validates_attachment_content_type :image, :content_type=>['image/
> jpeg', 'image/jpg', 'image/png', 'image/gif'],
>                 :message => 'can only be jpeg, jpg, png, or gif',
>                 :unless => Proc.new { |photo| photo[:image].nil? }
>
> end
>
> then I can upload an image. BUT I find that the following doesn't
> work:
>
> <%= image_tag panel.image.url(:medium) %>
> <%= image_tag panel.image.url(:thumb) %>
>
> ...while the regular, <%= image_tag panel.image.url %> works fine.  I
> have a feeling that the reason these two don't work is somehow tied to
> my first problem, when :whiny was not set to false.  Maybe the first
> error might somehow be responsible for the directory not getting made
> for the :medium and :thumb...each images in the 'systems/images'
> directory only has 'original' - no 'thumb' or 'medium.'
> But I don't know!  All I know is that the directory for thumb and
> medium don't get made, so those 2 lines of code won't work!
>
> Please helppp...this has been very frustrating

-- 
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-t...@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.



Re: [Rails] Re: Installation and versioning issues

2010-09-13 Thread radhames brito
go with RVM is clean and easy

-- 
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-t...@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.



Re: [Rails] Re: Deprecation warning with form_tag

2010-09-13 Thread radhames brito
watch this


http://railscasts.com/episodes/208-erb-blocks-in-rails-3

On Mon, Sep 13, 2010 at 4:09 PM, rodrigo3n  wrote:

> Thanks for the reply but this didn't work. Instead, I wrote this:
>
> <%= form_tag '/sessions' do -%>
>   <%= image_submit_tag 'login.png', :class => 'login' %>
> <% end -%>
>
> And it works and the deprecation method is gone.
>
> Thanks!
>
> On Sep 13, 3:53 pm, Greg Donald  wrote:
> > On Mon, Sep 13, 2010 at 1:47 PM, rodrigo3n  wrote:
> > > Hello everyone, I am using Rails 3 and receiving an deprecation
> > > warning when running the specs of my app. The warning:
> >
> > > ..*F.DEPRECATION WARNING: <% %> style block helpers are
> > > deprecated. Please use <%= %>. (called from
> > > <% form_tag 'sessions' do %>
> >
> > <%= form_tag do %>
> >
> > <% end %>
> >
> > --
> > Greg Donald
> > destiney.com | gregdonald.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-t...@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.
>
>

-- 
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-t...@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.



Re: [Rails] Indexing feature

2010-09-13 Thread radhames brito
you can trigger a rake task

On Mon, Sep 13, 2010 at 1:05 PM, Awijeet Mr.  wrote:

> How can I enable my admin to index the tables, just after he/she  makes
> change into database.
> --
> 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-t...@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.
>
>

-- 
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-t...@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] Paperclip - helppppp

2010-09-13 Thread daze
I keep seeing this error when I try to upload an image:
--
2 errors prohibited this panel from being saved

There were problems with the following fields:

Image C:/Users/Family/AppData/Local/Temp/stream,10032,0.png is not
recognized by the 'identify' command.
Image C:/Users/Family/AppData/Local/Temp/stream,10032,0.png is not
recognized by the 'identify' command.
--

If I have my model Panel (which needs an image attachment) look like
this, with the 'whiny' option set to false...

class Panel < ActiveRecord::Base
belongs_to :section
acts_as_list

has_attached_file :image, :styles => { :medium => "300x300>",:thumb
=> "100x100>" }, :whiny => false

validates_attachment_content_type :image, :content_type=>['image/
jpeg', 'image/jpg', 'image/png', 'image/gif'],
:message => 'can only be jpeg, jpg, png, or gif',
:unless => Proc.new { |photo| photo[:image].nil? }

end

then I can upload an image. BUT I find that the following doesn't
work:

<%= image_tag panel.image.url(:medium) %>
<%= image_tag panel.image.url(:thumb) %>

...while the regular, <%= image_tag panel.image.url %> works fine.  I
have a feeling that the reason these two don't work is somehow tied to
my first problem, when :whiny was not set to false.  Maybe the first
error might somehow be responsible for the directory not getting made
for the :medium and :thumb...each images in the 'systems/images'
directory only has 'original' - no 'thumb' or 'medium.'
But I don't know!  All I know is that the directory for thumb and
medium don't get made, so those 2 lines of code won't work!

Please helppp...this has been very frustrating

-- 
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-t...@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: Problems with the money gem

2010-09-13 Thread JSeidel
I've done all that; but since this is an ActiveRecord object, I was
hoping there was a way to do this in one spot, through a Rails hook,
rather than having to remember to code this each time.

The way I encapsulated all this was to create an initialize_to_zeros
method and now I call that each time after doing a model.new

...jon

On Sep 13, 8:56 am, Marnen Laibow-Koser  wrote:
> Please quote when replying, otherwise the discussion becomes impossible
> to follow.
>
> Jon Seidel wrote:
> > I do have default values specified, but these only take effect when
> > writing to the database, now when the new object is created.
>
> Yes, of course.  If you need them before that, put them in the
> constructor.
>
> (In other words: use Ruby's object model to your advantage! :) )
>
> Best,
> --
> Marnen Laibow-Koserhttp://www.marnen.org
> mar...@marnen.org
> --
> 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-t...@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: Installation and versioning issues

2010-09-13 Thread Robert Walker
Nick Dr wrote:
> Ok, I'm new to Rails, and I was hoping to get some advice on how to
> get started.
> 
> I'm coming from a .NET background, and from what I've seen of Rails,
> it looks perfect for a little web idea I had. So I got a book from the
> library and sat down to install it on my Ubuntu box. Immediately I hit
> versioning issues.
> 
> - I installed ruby with apt-get and it gave me 1.8.7. I'm cool with
> this as I'm new to Ruby as well, and am ignorant to the differences
> between versions.
> 
> - Installed rubygems and I got 1.3.5. Again, I don't know the
> difference

I highly recommend RVM (Ruby EnVironment Manager). RVM is really simple 
to install and it makes installing Ruby and RubyGems drop-dead simple. 
You get to have as many different rubies and gemsets as you want.

http://rvm.beginrescueend.com/

> - I ran 'sudo gem install rails', and it blew up on me, saying that I
> needed rubygems 1.3.6 or higher. When I do a gem list, it shows
> rails(3.0.0), which I hear just came out a week or two ago. Again, I
> don't know the difference so that's why I'm here. The book I got from
> the library is older(2007) and using Rails 1.2.3.

Again RVM solves this problem beautifully.

> So my question is: what's the easiest way to get this setup? Is there
> a major difference between the versions of Rails, and if so, what is
> it? I just need a plain vanilla setup so I can learn about MVC and
> such. This web app is pretty basic, I was just wanting some basic
> ActiveRecord, a few Erb templates and a few dozen lines of ruby
> business logic.

1. Install RVM
http://rvm.beginrescueend.com/rvm/install/

2. rvm install ruby-1.9.2
3. gem install rails
4. rails new my_project
5. Add what you need to Gemfile in your Rails project (like 
sqlite3-ruby, etc.)
6. bundle install
7. Read up on all the other cool stuff RVM gives you.
-- 
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-t...@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.



Re: [Rails] Installation and versioning issues

2010-09-13 Thread Philip Hallstrom
> library and sat down to install it on my Ubuntu box. Immediately I hit
> versioning issues.
> 
> - I installed ruby with apt-get and it gave me 1.8.7. I'm cool with
> this as I'm new to Ruby as well, and am ignorant to the differences
> between versions.

1.8.7 is fine.

> - Installed rubygems and I got 1.3.5. Again, I don't know the
> difference

Ubuntu (and Debian) have some issues with rubygems... try installing it 
directly...

http://rubygems.org/


> - I ran 'sudo gem install rails', and it blew up on me, saying that I
> needed rubygems 1.3.6 or higher. When I do a gem list, it shows
> rails(3.0.0), which I hear just came out a week or two ago. Again, I
> don't know the difference so that's why I'm here. The book I got from
> the library is older(2007) and using Rails 1.2.3.

Take the book back to the library.  Things have changed enough that that book 
is just going to mess you up.

> So my question is: what's the easiest way to get this setup?

http://guides.rubyonrails.org/

> Is there a major difference between the versions of Rails, and if so, what is
> it?

Yes.  Anything prior to 2.3.9 is old.  Your choice right now is whether to go 
with 2.3.9 or 3.0.0.  If you're just starting out on a small project, I'd 
probably go with 3.0.0 as that's where the future is going and enough has 
changed that you might as well start there.  

The only drawback is I don't think any books are out yet for 3.0, but there 
should be plenty of online articles... 

> Can someone point me in the right direction?

I'd start with these two sites...

http://guides.rubyonrails.org/
http://railscasts.com/ (look for 3.0 specific stuff)

-philip

-- 
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-t...@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] Installation and versioning issues

2010-09-13 Thread Boosh
Ok, I'm new to Rails, and I was hoping to get some advice on how to
get started.

I'm coming from a .NET background, and from what I've seen of Rails,
it looks perfect for a little web idea I had. So I got a book from the
library and sat down to install it on my Ubuntu box. Immediately I hit
versioning issues.

- I installed ruby with apt-get and it gave me 1.8.7. I'm cool with
this as I'm new to Ruby as well, and am ignorant to the differences
between versions.

- Installed rubygems and I got 1.3.5. Again, I don't know the
difference

- I ran 'sudo gem install rails', and it blew up on me, saying that I
needed rubygems 1.3.6 or higher. When I do a gem list, it shows
rails(3.0.0), which I hear just came out a week or two ago. Again, I
don't know the difference so that's why I'm here. The book I got from
the library is older(2007) and using Rails 1.2.3.

So my question is: what's the easiest way to get this setup? Is there
a major difference between the versions of Rails, and if so, what is
it? I just need a plain vanilla setup so I can learn about MVC and
such. This web app is pretty basic, I was just wanting some basic
ActiveRecord, a few Erb templates and a few dozen lines of ruby
business logic.

Can someone point me in the right direction?

-- 
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-t...@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] Routing question

2010-09-13 Thread Luis Correa d'Almeida
Hello

Given the following rules

MyApp::Application.routes.draw do |map|

resources :accounts do
resources :comments
end

match '*path' => redirect("/accounts/%{path}")

end

Can we get ActionDispatch to, rather than redirect, re-run the routes?
This would come in handy for using account handles, as in

http://mymusicwebsite.com/metallica
http://mymusicwebsite.com/metallica/comments
http://mymusicwebsite.com/metallica/comments/2

rather than

http://mymusicwebsite.com/accounts/metallica
http://mymusicwebsite.com/accounts/metallica/comments
http://mymusicwebsite.com/accounts/metallica/comments/2

Any help appreciated.

-- 
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-t...@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 3: finding a record by name in multilingual app

2010-09-13 Thread Michael Schuerig
On Monday 13 September 2010, Heinz Strunk wrote:
> > This is completely fishy. Rails is not supposed to translate
> > strings behind your back. Are you any extensions (gems, plugins)
> > that may try to be helpful in the wrong way?
> 
> Well, I used globalize2 when I used Rails 2.3.8 and everything worked
> perfectly fine but no new gems or anything eversince. Must be
> globalize3 or something...
> 
> > Out of the box, #find_by_name behaves exactly the same as
> > #find_by_foobar, which is to say, it executes an SQL statement
> > containing a comparison of column "name" with the string you
> > provide. It looks like a call to I18n.translate has been slipped
> > in somewhere.
> > 
> > Do you get the same result for Page.where(:name =>
> > 'Welcome').first?
> 
> where doesn't work because it's in a different table:
> Page.where(:name => 'Willkommen')
> ActiveRecord::StatementInvalid: Mysql::BadFieldError: Unknown column
> 'pages.name' in 'where clause': SELECT `pages`.* FROM `pages` WHERE
> (`pages`.`name` = 'Willkommen')

Well, after looking at the globalize3 code (specifically 
lib/globalize/active_record/class_methods.rb), I see *why* you get the 
result you do. The code is actually quite ingenious (or flabberghastly, 
depending on how you look at it).

Anyway, I think(!) you get what you want, if you simply write

with_locale(:en) {
  Page.find_by_name('Welcome')
}

For more details, have a look at the tests that come with globalize3.

Michael

-- 
Michael Schuerig
mailto:mich...@schuerig.de
http://www.schuerig.de/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-t...@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.



Re: [Rails] what I've missed in routes.rb?

2010-09-13 Thread radhames brito
no, that his is a way to build the route

resources :something, :except => :destroy do
delete :destroy, :on => :collection, :as => :destroy
end

On Mon, Sep 13, 2010 at 4:03 PM, Greg Donald  wrote:

> On Mon, Sep 13, 2010 at 3:00 PM, radhames brito  wrote:
> >
> > yes i agree
>
> That you don't know how to trim a post?
>
>
> --
> Greg Donald
> destiney.com | gregdonald.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-t...@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.
>
>

-- 
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-t...@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: Deprecation warning with form_tag

2010-09-13 Thread rodrigo3n
Thanks for the reply but this didn't work. Instead, I wrote this:

<%= form_tag '/sessions' do -%>
  <%= image_submit_tag 'login.png', :class => 'login' %>
<% end -%>

And it works and the deprecation method is gone.

Thanks!

On Sep 13, 3:53 pm, Greg Donald  wrote:
> On Mon, Sep 13, 2010 at 1:47 PM, rodrigo3n  wrote:
> > Hello everyone, I am using Rails 3 and receiving an deprecation
> > warning when running the specs of my app. The warning:
>
> > ..*F.DEPRECATION WARNING: <% %> style block helpers are
> > deprecated. Please use <%= %>. (called from
> > <% form_tag 'sessions' do %>
>
> <%= form_tag do %>
>
> <% end %>
>
> --
> Greg Donald
> destiney.com | gregdonald.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-t...@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.



Re: [Rails] Re: Re: formtastic options

2010-09-13 Thread radhames brito
sorry i meant to say
 you can put normal tags in it i have and is works.

On Mon, Sep 13, 2010 at 4:07 PM, radhames brito  wrote:

> you can out nor mas tags in it i have and is works.
>
> this in the view
>
> check_box_tag :thing
>
>
> in the controller
>
>
> item.thing = params[:thing]
>
>
> On Mon, Sep 13, 2010 at 3:59 PM, Jamal Soueidan wrote:
>
>> radhames brito wrote:
>> > sorry i thought you wanted to add some html options , but now that i
>> > read
>> > again i see you want to add more html to the output.
>>
>>
>> Nobody knows how to create custom input field with formtastic.
>>
>> I thought this plugin was known around.
>> --
>> 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-t...@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.
>>
>>
>

-- 
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-t...@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.



Re: [Rails] Re: Re: formtastic options

2010-09-13 Thread radhames brito
you can out nor mas tags in it i have and is works.

this in the view

check_box_tag :thing


in the controller


item.thing = params[:thing]

On Mon, Sep 13, 2010 at 3:59 PM, Jamal Soueidan wrote:

> radhames brito wrote:
> > sorry i thought you wanted to add some html options , but now that i
> > read
> > again i see you want to add more html to the output.
>
>
> Nobody knows how to create custom input field with formtastic.
>
> I thought this plugin was known around.
> --
> 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-t...@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.
>
>

-- 
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-t...@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: Re: Re: after_create not being called in seeds.rb?

2010-09-13 Thread Heinz Strunk
Ah, I see. Yeah, after_create seems better after all.
-- 
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-t...@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: Re: Re: Rails 3: finding a record by name in multilingual app

2010-09-13 Thread Heinz Strunk
Nope not yet but you said you'll try to help and appreciate it.
-- 
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-t...@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.



Re: [Rails] what I've missed in routes.rb?

2010-09-13 Thread Greg Donald
On Mon, Sep 13, 2010 at 3:00 PM, radhames brito  wrote:
>
> yes i agree

That you don't know how to trim a post?


--
Greg Donald
destiney.com | gregdonald.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-t...@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.



Re: [Rails] what I've missed in routes.rb?

2010-09-13 Thread radhames brito
yes i agree

On Mon, Sep 13, 2010 at 3:57 PM, Daniel Gaytán  wrote:

> Then it may be set as resource instead of resources
>
> or maybe
>
> resources :something, :except => :destroy do
> delete :destroy, :on => :collection, :as => :destroy
> end
>
> Daniel Gaytán
>
>
> 2010/9/13 radhames brito 
>
>> @Daniel Gaytán
>> but the default destroy route will still wait for an id, and he doesnt
>> needs if since the user is in the session
>>
>>
>>
>>
>>
>> On Mon, Sep 13, 2010 at 3:38 PM, Daniel Gaytán <
>> daniel.gaytan.n...@gmail.com> wrote:
>>
>>> I think you are missing the rails javascript file, which is who actually
>>> handles the special links.
>>>
>>> When you click on the link, the method is GET, so you don't hace any
>>> toute related to the action destroy in that method.
>>>
>>> Daniel Gaytán
>>>
>>>
>>>
>>> 2010/9/13 radhames brito 
>>>
  i think you should,

 resources user, :except => :destroy
 then
 match   you path here


 On Mon, Sep 13, 2010 at 11:55 AM, Mauro  wrote:

> On 13 September 2010 16:02, radhames brito  wrote:
> > the default destroy route is
> > /controller/id , :method=> delete
> > {:action=>"destroy", :controller=>"sessions", :id=>"name.surname"}
> >
> > but your destroy action does not need an id really,
>
> So I've to change the default destroy route for sessions resource?
>
> --
> 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.
>
>
  --
 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-t...@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.

>>>
>>>  --
>>> 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-t...@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.
>>>
>>
>>  --
>> 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-t...@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.
>>
>
>  --
> 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-t...@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.
>

-- 
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-t...@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: Re: formtastic options

2010-09-13 Thread Jamal Soueidan
radhames brito wrote:
> sorry i thought you wanted to add some html options , but now that i 
> read
> again i see you want to add more html to the output.


Nobody knows how to create custom input field with formtastic.

I thought this plugin was known around.
-- 
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-t...@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.



Re: [Rails] what I've missed in routes.rb?

2010-09-13 Thread Daniel Gaytán
Then it may be set as resource instead of resources

or maybe

resources :something, :except => :destroy do
delete :destroy, :on => :collection, :as => :destroy
end

Daniel Gaytán


2010/9/13 radhames brito 

> @Daniel Gaytán
> but the default destroy route will still wait for an id, and he doesnt
> needs if since the user is in the session
>
>
>
>
>
> On Mon, Sep 13, 2010 at 3:38 PM, Daniel Gaytán <
> daniel.gaytan.n...@gmail.com> wrote:
>
>> I think you are missing the rails javascript file, which is who actually
>> handles the special links.
>>
>> When you click on the link, the method is GET, so you don't hace any toute
>> related to the action destroy in that method.
>>
>> Daniel Gaytán
>>
>>
>>
>> 2010/9/13 radhames brito 
>>
>>>  i think you should,
>>>
>>> resources user, :except => :destroy
>>> then
>>> match   you path here
>>>
>>>
>>> On Mon, Sep 13, 2010 at 11:55 AM, Mauro  wrote:
>>>
 On 13 September 2010 16:02, radhames brito  wrote:
 > the default destroy route is
 > /controller/id , :method=> delete
 > {:action=>"destroy", :controller=>"sessions", :id=>"name.surname"}
 >
 > but your destroy action does not need an id really,

 So I've to change the default destroy route for sessions resource?

 --
 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-t...@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.


>>>  --
>>> 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-t...@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.
>>>
>>
>>  --
>> 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-t...@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.
>>
>
>  --
> 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-t...@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.
>

-- 
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-t...@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.



Re: [Rails] Re: Re: after_create not being called in seeds.rb?

2010-09-13 Thread radhames brito
sorry now i see it makes no sense, i understood that this is all in your
seed.rb and both functions will only be used once and i was suggesting this

100.times do
  user = User.new
  user.username = Faker::Name.first_name
  user.email = user.username+"@example.com"
  user.save!
  write_comments(user)   <===  this could be in your controller create
action
end

protected
def write_comments(user)
 comment = Comment.new
 comment.text = "some text"
 comment.user = user
 comment.save!
end


After paying more attention to your comment i notice you want the
write_comments to be in your model in production, and my suggestion made no
sense.




On Mon, Sep 13, 2010 at 3:47 PM, Heinz Strunk  wrote:

> > put the function in the loop after the user.save ?
> What exactly do you mean by put it in the loop after .save?
> --
> 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-t...@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.
>
>

-- 
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-t...@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: Re: after_create not being called in seeds.rb?

2010-09-13 Thread Heinz Strunk
> put the function in the loop after the user.save ?
What exactly do you mean by put it in the loop after .save?
-- 
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-t...@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.



Re: [Rails] Re: Re: Rails 3: finding a record by name in multilingual app

2010-09-13 Thread radhames brito
so is it working?

On Mon, Sep 13, 2010 at 3:43 PM, Heinz Strunk  wrote:

> > yes i understand what you say now, but it seems that is a problem with
> > the
> > gem. I dont know globalize2 ill read on it and try to help.
>
> Thanks in advance I do appreciate but I'm using globalize3 and not 2
> anymore :)
> --
> 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-t...@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.
>
>

-- 
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-t...@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: Re: Rails 3: finding a record by name in multilingual app

2010-09-13 Thread Heinz Strunk
> yes i understand what you say now, but it seems that is a problem with 
> the
> gem. I dont know globalize2 ill read on it and try to help.

Thanks in advance I do appreciate but I'm using globalize3 and not 2 
anymore :)
-- 
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-t...@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] ri-cal mysql table

2010-09-13 Thread Pål Bergström
Which columns should a ri-cal calendar table in mysql have?
-- 
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-t...@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.



Re: [Rails] what I've missed in routes.rb?

2010-09-13 Thread radhames brito
@Daniel Gaytán
but the default destroy route will still wait for an id, and he doesnt needs
if since the user is in the session





On Mon, Sep 13, 2010 at 3:38 PM, Daniel Gaytán  wrote:

> I think you are missing the rails javascript file, which is who actually
> handles the special links.
>
> When you click on the link, the method is GET, so you don't hace any toute
> related to the action destroy in that method.
>
> Daniel Gaytán
>
>
>
> 2010/9/13 radhames brito 
>
>> i think you should,
>>
>> resources user, :except => :destroy
>> then
>> match   you path here
>>
>>
>> On Mon, Sep 13, 2010 at 11:55 AM, Mauro  wrote:
>>
>>> On 13 September 2010 16:02, radhames brito  wrote:
>>> > the default destroy route is
>>> > /controller/id , :method=> delete
>>> > {:action=>"destroy", :controller=>"sessions", :id=>"name.surname"}
>>> >
>>> > but your destroy action does not need an id really,
>>>
>>> So I've to change the default destroy route for sessions resource?
>>>
>>> --
>>> 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-t...@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.
>>>
>>>
>>  --
>> 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-t...@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.
>>
>
>  --
> 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-t...@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.
>

-- 
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-t...@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.



Re: [Rails] Re: Rails Commenting, Plugins?

2010-09-13 Thread Michael Pavling
On 13 September 2010 20:36, radhames brito  wrote:
> By instant update i mean, displaying the comment without the need for
> approval

I agree - that's a crazy thing to do! (AJAX or not ;-)

-- 
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-t...@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.



Re: [Rails] what I've missed in routes.rb?

2010-09-13 Thread Daniel Gaytán
I think you are missing the rails javascript file, which is who actually
handles the special links.

When you click on the link, the method is GET, so you don't hace any toute
related to the action destroy in that method.

Daniel Gaytán



2010/9/13 radhames brito 

> i think you should,
>
> resources user, :except => :destroy
> then
> match   you path here
>
>
> On Mon, Sep 13, 2010 at 11:55 AM, Mauro  wrote:
>
>> On 13 September 2010 16:02, radhames brito  wrote:
>> > the default destroy route is
>> > /controller/id , :method=> delete
>> > {:action=>"destroy", :controller=>"sessions", :id=>"name.surname"}
>> >
>> > but your destroy action does not need an id really,
>>
>> So I've to change the default destroy route for sessions resource?
>>
>> --
>> 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-t...@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.
>>
>>
>  --
> 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-t...@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.
>

-- 
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-t...@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.



Re: [Rails] Re: Rails Commenting, Plugins?

2010-09-13 Thread radhames brito
By instant update i mean, displaying the comment without the need for
approval

On Mon, Sep 13, 2010 at 3:35 PM, radhames brito  wrote:

> yes , think there is  a language barrier and some of my ideas dont get
> through the way i want them to.
>
> I for example use ajax to update comments that i publish/approve, but not
> for instant update.
>
>
> On Mon, Sep 13, 2010 at 3:27 PM, Michael Pavling wrote:
>
>> On 13 September 2010 20:14, radhames brito  wrote:
>> > my point was that is you have a °publishing/approval" page there is no
>> use
>> > for ajax.
>> >
>>
>> Unless the comment form is a small component of the page, and you
>> don't want to reload the whole page when the user makes a comment, and
>> you do want to pop up a nice transitional effect and notification when
>> they do you know, the stuff AJAX makes all pretty...
>>
>> Your original reply implied that there was something inherently
>> insecure about using AJAX methods - this is *not* the case. They're as
>> secure or insecure as you make them.
>>
>> --
>> 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-t...@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.
>>
>>
>

-- 
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-t...@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.



Re: [Rails] Re: Rails Commenting, Plugins?

2010-09-13 Thread radhames brito
yes , think there is  a language barrier and some of my ideas dont get
through the way i want them to.

I for example use ajax to update comments that i publish/approve, but not
for instant update.

On Mon, Sep 13, 2010 at 3:27 PM, Michael Pavling  wrote:

> On 13 September 2010 20:14, radhames brito  wrote:
> > my point was that is you have a °publishing/approval" page there is no
> use
> > for ajax.
> >
>
> Unless the comment form is a small component of the page, and you
> don't want to reload the whole page when the user makes a comment, and
> you do want to pop up a nice transitional effect and notification when
> they do you know, the stuff AJAX makes all pretty...
>
> Your original reply implied that there was something inherently
> insecure about using AJAX methods - this is *not* the case. They're as
> secure or insecure as you make them.
>
> --
> 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-t...@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.
>
>

-- 
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-t...@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.



Re: [Rails] Re: after_create not being called in seeds.rb?

2010-09-13 Thread radhames brito
jojo, now i see what you are doing, is just that i didnt saw the after
create the first time, you are using the self reserved word indeed to refer
to the created user in the after create, have you tried that before? why not
put the function in the loop after the user.save ?

i imagine that that it fail quietly?

On Mon, Sep 13, 2010 at 12:03 PM, Heinz Strunk  wrote:

> @brito: self always worked cause it's the instance of the current object
> which I wanna use so that should be fine.
>
> @Marnen: Actually they're not really users but NPCs which I need for
> various things and I need a lot of them to populate the world.
>
> Therefore it's not for test but to populate and I don't think factories
> are good for so many objects, right?
> --
> 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-t...@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.
>
>

-- 
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-t...@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.



Re: [Rails] Re: Re: STI and nested object on subclass

2010-09-13 Thread Daniel Gaytán
Hello  Javier,

I was just checking the set_table_name class method of ActiveRecord and I
think that could work for you:

class AnotherClass < ActiveRecord::Base
  has_one :worker
end

class Person < ActiveRecord::Base
  def something
self.name
  end
end

class Worker < Person
  set_table_name "workers"
end

w = Worker.create(:name => "WorkerName")
p = Person.create(:name => "PersonName")
ac = AnotherClass.create

ac.worker = w
ac.save

ac.worker.something # => "WorkerName"

I hope that would be helpful

Daniel Gaytán

2010/9/13 Marnen Laibow-Koser 

> [Please quote when replying.  Otherwise the discussion is impossible to
> follow.]
>
> Javier Ruiz wrote:
> > Yep that's finally how I will have to do it... but this is not what I
> > wanted. A has_one relation means that I have to access things like:
> >
> > Anotherclass.property
> > Anotherclass.childclass.specific_property
> > Anotherclass.childclass.parentclass.common_property
>
> That makes sense from a relational point of view.  If you don't like it,
> then use STI.
>
> >
> > And more important... I need to manually manage related objects (or
> > create hooks os similar). I mean I need for example to do something
> > like:
> >
> > a = Anotherclass.new
> > b = Childclass.new
> > a.childclass = b
> >
> > ... and so on...
>
> You'd need to do that regardless of whether your original idea worked.
>
> >
> > I was thinking "rails' magic" was really magic ;-)
>
> I suppose it is, but it doesn't extend to spreading one class across
> multiple tables.
>
> If you were ambitious, you probably *could* extend ActiveRecord to do
> that, but I'm not sure it's a good idea -- it's trying to impose too
> much of an OO approach on a relational DB.  Alternatively, you could try
> an OODB like GemStone/MagLev.
>
> 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-t...@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.
>
>

-- 
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-t...@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.



Re: [Rails] Re: Rails Commenting, Plugins?

2010-09-13 Thread Michael Pavling
On 13 September 2010 20:14, radhames brito  wrote:
> my point was that is you have a °publishing/approval" page there is no use
> for ajax.
>

Unless the comment form is a small component of the page, and you
don't want to reload the whole page when the user makes a comment, and
you do want to pop up a nice transitional effect and notification when
they do you know, the stuff AJAX makes all pretty...

Your original reply implied that there was something inherently
insecure about using AJAX methods - this is *not* the case. They're as
secure or insecure as you make them.

-- 
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-t...@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.



Re: [Rails] Re: Rails 3: finding a record by name in multilingual app

2010-09-13 Thread radhames brito
sorry for not answering busy.


yes i understand what you say now, but it seems that is a problem with the
gem. I dont know globalize2 ill read on it and try to help.



On Mon, Sep 13, 2010 at 2:40 PM, Heinz Strunk  wrote:

> > This is completely fishy. Rails is not supposed to translate strings
> > behind your back. Are you any extensions (gems, plugins) that may try to
> > be helpful in the wrong way?
> Well, I used globalize2 when I used Rails 2.3.8 and everything worked
> perfectly fine but no new gems or anything eversince. Must be globalize3
> or something...
> >
> > Out of the box, #find_by_name behaves exactly the same as
> > #find_by_foobar, which is to say, it executes an SQL statement
> > containing a comparison of column "name" with the string you provide. It
> > looks like a call to I18n.translate has been slipped in somewhere.
> >
> > Do you get the same result for Page.where(:name => 'Welcome').first?
> where doesn't work because it's in a different table:
> Page.where(:name => 'Willkommen')
> ActiveRecord::StatementInvalid: Mysql::BadFieldError: Unknown column
> 'pages.name' in 'where clause': SELECT `pages`.* FROM `pages` WHERE
> (`pages`.`name` = 'Willkommen')
> >
> > In order to find the real cause, your best bet is to use the debugger
> > and step into the misbehaving statement.
> I guess I have no other choice...
>
> Just to make my problem a bit more clear:
> irb(main):030:0> I18n.locale = :de
> => :de
> irb(main):031:0> Page.find_by_name("Welcome")
> => []
> irb(main):032:0> Page.find_by_name("Willkommen")
> => [# 12:55:41", updated_at: "2010-09-12 12:55:41">]
> irb(main):033:0> I18n.locale = :en
> => :en
> irb(main):034:0> Page.find_by_name("Welcome")
> => [# 12:55:41", updated_at: "2010-09-12 12:55:41">]
> irb(main):035:0> Page.find_by_name("Willkommen")
> => []
>
> Before I upgraded to Rails 3 all four queries returned the same result.
> --
> 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-t...@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.
>
>

-- 
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-t...@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] Problem with attr_accessor

2010-09-13 Thread Pål Bergström
I pass a value from controller to model with attr_accessor. before_save
works fine but not after_find. What could be wrong?

This is what I use in index
@test = Test.find(:all)
@test.each {|a| a.key = cookies[:thekey]}

and this in create, show, edit:

@test.key = cookies[:thekey]

This is my model:
attr_accessor :key

after_find :decrypt_data
define_method(:after_find) { }
before_save :crypt_data

private

def crypt_data
  self.name = Crypto.encrypt(self.name,key)
end

def decrypt_data
  self.name = Crypto.decrypt(self.name,key)
end
-- 
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-t...@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.



Re: [Rails] what I've missed in routes.rb?

2010-09-13 Thread radhames brito
i think you should,

resources user, :except => :destroy
then
match   you path here

On Mon, Sep 13, 2010 at 11:55 AM, Mauro  wrote:

> On 13 September 2010 16:02, radhames brito  wrote:
> > the default destroy route is
> > /controller/id , :method=> delete
> > {:action=>"destroy", :controller=>"sessions", :id=>"name.surname"}
> >
> > but your destroy action does not need an id really,
>
> So I've to change the default destroy route for sessions resource?
>
> --
> 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-t...@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.
>
>

-- 
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-t...@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.



Re: [Rails] Re: Rails Commenting, Plugins?

2010-09-13 Thread radhames brito
my point was that is you have a °publishing/approval" page there is no use
for ajax.

On Mon, Sep 13, 2010 at 11:46 AM, Michael Pavling  wrote:

> On 13 September 2010 13:36, radhames brito  wrote:
> > "What does using AJAX or not have to do with whether or not you use a
> > CAPTCHA process?"
> >
> > because some bots will bypass the captcha, and he will need a publishing
> > page  where he can delete those spams that get through because captcha
> alone
> > is not enough so at the end captcha is only an aid to stop most of the
> spam
> > but not all.
>
> Any bots that can bypass an AJAX captcha could bypass the same captcha
> on a non-AJAX submission.
> And AJAX or not, the choice is up to you whether to have a
> "publishing/approval" page.
>
> Again - There's nothing special about AJAX that makes any
> implementation of a "commentable" feature inherently less secure. It's
> *exactly* the same as a normal form submission/process procedure, just
> performed by Javascript and in the background to the user.
>
> --
> 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-t...@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.
>
>

-- 
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-t...@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: after_create not being called in seeds.rb?

2010-09-13 Thread Heinz Strunk
For some stupid reason it's working now. My guess is a Windows reboot 
did the magic ;) It is indeed much nicher!

Thanks everybody!
-- 
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-t...@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.



Re: [Rails] Deprecation warning with form_tag

2010-09-13 Thread Greg Donald
On Mon, Sep 13, 2010 at 1:47 PM, rodrigo3n  wrote:
> Hello everyone, I am using Rails 3 and receiving an deprecation
> warning when running the specs of my app. The warning:
>
>
> ..*F.DEPRECATION WARNING: <% %> style block helpers are
> deprecated. Please use <%= %>. (called from
> <% form_tag 'sessions' do %>

<%= form_tag do %>

<% end %>


-- 
Greg Donald
destiney.com | gregdonald.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-t...@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] Deprecation warning with form_tag

2010-09-13 Thread rodrigo3n
Hello everyone, I am using Rails 3 and receiving an deprecation
warning when running the specs of my app. The warning:


..*F.DEPRECATION WARNING: <% %> style block helpers are
deprecated. Please use <%= %>. (called from
_app_views_sessions_new_html_erb___526016660_85924870_644960759 at /
home/orygens/code/narciso/app/views/sessions/new.html.erb:9)
.F.F..*.

This message is about the following code:

<% form_tag 'sessions' do %>
  <%= image_submit_tag 'login.png', :class => 'login' %>
<% end %>

This logs in the user who remains at the same path after the login.

Do you know how to correct the code so I can ensure this code won't
break my app in the future?

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-t...@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.



Re: [Rails] Re: How to disable a select?

2010-09-13 Thread Srikanth Shreenivas
Try

f.select :attr, @choices, {:include_blank => true}, { :disabled =>
!...@condition }

On Mon, Sep 13, 2010 at 11:44 PM, Fritz Trapper wrote:

> Marnen Laibow-Koser wrote:
> > Are you sure !...@condition is true when you expect it to be?
>
> Yes, I checked it in the debugger.
>  --
> 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-t...@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.
>
>

-- 
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-t...@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 3: finding a record by name in multilingual app

2010-09-13 Thread Heinz Strunk
> This is completely fishy. Rails is not supposed to translate strings
> behind your back. Are you any extensions (gems, plugins) that may try to
> be helpful in the wrong way?
Well, I used globalize2 when I used Rails 2.3.8 and everything worked 
perfectly fine but no new gems or anything eversince. Must be globalize3 
or something...
> 
> Out of the box, #find_by_name behaves exactly the same as
> #find_by_foobar, which is to say, it executes an SQL statement
> containing a comparison of column "name" with the string you provide. It
> looks like a call to I18n.translate has been slipped in somewhere.
> 
> Do you get the same result for Page.where(:name => 'Welcome').first?
where doesn't work because it's in a different table:
Page.where(:name => 'Willkommen')
ActiveRecord::StatementInvalid: Mysql::BadFieldError: Unknown column 
'pages.name' in 'where clause': SELECT `pages`.* FROM `pages` WHERE 
(`pages`.`name` = 'Willkommen')
> 
> In order to find the real cause, your best bet is to use the debugger
> and step into the misbehaving statement.
I guess I have no other choice...

Just to make my problem a bit more clear:
irb(main):030:0> I18n.locale = :de
=> :de
irb(main):031:0> Page.find_by_name("Welcome")
=> []
irb(main):032:0> Page.find_by_name("Willkommen")
=> [#]
irb(main):033:0> I18n.locale = :en
=> :en
irb(main):034:0> Page.find_by_name("Welcome")
=> [#]
irb(main):035:0> Page.find_by_name("Willkommen")
=> []

Before I upgraded to Rails 3 all four queries returned the same result.
-- 
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-t...@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 disable a select?

2010-09-13 Thread Fritz Trapper
Marnen Laibow-Koser wrote:
> Are you sure !...@condition is true when you expect it to be?

Yes, I checked it in the debugger.
-- 
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-t...@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.



Re: [Rails] Re: ruby-debug does not invoke from rspec (rails 3 rspec beta 22)

2010-09-13 Thread David Kahn
>
>
> Perhaps auto-eval is turned off in the debugger.  Try typing "p
> @user_session" instead of "@user_session".
>

Thanks -- worked perfectly.


>
> And why are you using RSpec specs for your controllers, anyway?
> Cucumber stories are better for that.  RSpec is better for model logic.
>
>
Well, I was hoping to cap new things on this project with Rails 3, ruby
1.9.2, rspec, factory girl. is getting cucumber up and running is pretty
incidental?


> >
> >
> > So, how does one go about debugging their tests, or rather specs, in
> > rspec?
>
> 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-t...@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.
>
>

-- 
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-t...@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: Query Multiple tables

2010-09-13 Thread Jeff
On Sep 13, 6:10 am, Frederick Cheung 
wrote:
> On Sep 13, 11:59 am, PalaniKannan K  wrote:> Hi,
>
> > select * from table1 inner join table2 on table1.foreign_key =
> > table2.foreign_key
>
> > select * from table1 inner join table2 on table1.foreign_key =
> > table2.foreign_key join table3 on table2.foreign_key=table3.foreign_key
>
> > These  are the SQL commands, I need to apply it in Rails. Kindly tell me the
> > syntax in Rails to apply these SQL commands instead of sql_query.
>
> Take a look at the :joins option to find (or the joins scope
> modifiying thing in rails 3)
>
> Fred
>

I think has_many :through might also be what you're looking for.  You
can avoid writing SQL 99% of the time if you learn how to use the
various flavors of ActiveRecord associations.

Jeff

-- 
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-t...@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: ruby-debug does not invoke from rspec (rails 3 rspec beta 22)

2010-09-13 Thread Marnen Laibow-Koser
David Kahn wrote:
> Ok, now I found if I add   *require 'ruby-debug'*   in the spec itself 
> the
> debugger invokes. However
> 
> It is useless. I get a breakpoint in my controller but have no access to
> anything I want:
> 
> ../Users/DK/Documents/ror/projects/wavelineup3/app/controllers/user_sessions_controller.rb:14
> respond_to do |format|
> (rdb:1) @user_session
> *** Unknown command: "@user_session".  Try "help".
> (rdb:1) self
> *** Unknown command: "self".  Try "help".
> (rdb:1) params
> *** Unknown command: "params".  Try "help".
> (rdb:1)

Perhaps auto-eval is turned off in the debugger.  Try typing "p 
@user_session" instead of "@user_session".

And why are you using RSpec specs for your controllers, anyway? 
Cucumber stories are better for that.  RSpec is better for model logic.

> 
> 
> So, how does one go about debugging their tests, or rather specs, in 
> rspec?

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-t...@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: Re: Re: Re: Authlogic Rails 3

2010-09-13 Thread Paul Mr
Paul Mr wrote:
> Rick R wrote:
>> On Sun, Sep 12, 2010 at 10:14 PM, Paul Mr  wrote:
> 
> thats what Im betting on.

Pretty much.. that one creates all the models/scaffolds/controllers the 
usual way...not even caring about Authlogic::Session::Base

though I assume possibly, manually editing the one item to reflect that 
instead of activerecord (or whatever it was).
-- 
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-t...@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: after_create not being called in seeds.rb?

2010-09-13 Thread Michael Schuerig
On Sunday 12 September 2010, Heinz Strunk wrote:

> after_create :write_comments
> 
> protected
> def write_comments
>   comment = Comment.new
>   comment.text = "some text"
>   comment.user = self
>   comment.save!
> end
> 
> There's not one single comment in the database but when I create a
> user using the console the comment is created after I save the user.

Is the after_create callback ever executed? Add a puts to make sure.

> Anyone knows what's wrong here?

I wouldn't write code like that to begin with. This is much nicer:

def write_comments
  user.comments.create!(:text => 'some text')
end

Michael

-- 
Michael Schuerig
mailto:mich...@schuerig.de
http://www.schuerig.de/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-t...@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: ruby-debug does not invoke from rspec (rails 3 rspec beta 22)

2010-09-13 Thread David Kahn
Ok, now I found if I add   *require 'ruby-debug'*   in the spec itself the
debugger invokes. However

It is useless. I get a breakpoint in my controller but have no access to
anything I want:

../Users/DK/Documents/ror/projects/wavelineup3/app/controllers/user_sessions_controller.rb:14
respond_to do |format|
(rdb:1) @user_session
*** Unknown command: "@user_session".  Try "help".
(rdb:1) self
*** Unknown command: "self".  Try "help".
(rdb:1) params
*** Unknown command: "params".  Try "help".
(rdb:1)


So, how does one go about debugging their tests, or rather specs, in rspec?





On Mon, Sep 13, 2010 at 5:17 PM, David Kahn wrote:

> Anyone know how to get ruby-debug (ruby-debug19) to invoke when running my
> specs? When I place 'debugger' in my controller and run the spec, it just
> skips over it.
>
> I have  require 'ruby-debug'  in spec_helper.rb
>
> Rails 3, ruby 1.9.2, ruby-debug19, rspec 2.0.0.beta.22
>
>
>

-- 
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-t...@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: after_create not being called in seeds.rb?

2010-09-13 Thread Heinz Strunk
Marnen Laibow-Koser wrote:
> Please quote when replying; otherwise, it gets difficult to follow the 
> discussion.
> 
> 
> So this is actual production data?
Yes, it is.
> 
> It's not appropriate to use an after_create for this sort of thing, I 
> think.  In your 100.times block, just create a comment when you create 
> each user.
Makes sense for comments but there but there's stuff like attributes 
etc. which needs to be created even when a user is created from the web 
interface. Do you know why the code above doesn't work?
-- 
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-t...@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 3: finding a record by name in multilingual app

2010-09-13 Thread Michael Schuerig
On Monday 13 September 2010, Heinz Strunk wrote:
> Well, I have been using Page.find_by_name("Welcome") in my code all
> the time when I was on Rails 2 (and globalize2, of course) and no
> matter what language was selected by the user it was always possible
> to load the welcome page with this command:
> Page.find_by_name("Welcome")
> 
> Eversince I switched to Rails 3 Page.find_by_name("Welcome") doesn't
> work anymore if there's another language selected but English which
> sucks cause I'd need to wrap an if clause checking for the language
> and then do one of these:

This is completely fishy. Rails is not supposed to translate strings 
behind your back. Are you any extensions (gems, plugins) that may try to 
be helpful in the wrong way?

Out of the box, #find_by_name behaves exactly the same as 
#find_by_foobar, which is to say, it executes an SQL statement 
containing a comparison of column "name" with the string you provide. It 
looks like a call to I18n.translate has been slipped in somewhere.

Do you get the same result for Page.where(:name => 'Welcome').first?

In order to find the real cause, your best bet is to use the debugger 
and step into the misbehaving statement.

Michael

-- 
Michael Schuerig
mailto:mich...@schuerig.de
http://www.schuerig.de/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-t...@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] ruby-debug does not invoke from rspec (rails 3 rspec beta 22)

2010-09-13 Thread David Kahn
Anyone know how to get ruby-debug (ruby-debug19) to invoke when running my
specs? When I place 'debugger' in my controller and run the spec, it just
skips over it.

I have  require 'ruby-debug'  in spec_helper.rb

Rails 3, ruby 1.9.2, ruby-debug19, rspec 2.0.0.beta.22

-- 
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-t...@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] Indexing feature

2010-09-13 Thread Awijeet Mr.
How can I enable my admin to index the tables, just after he/she  makes
change into database.
-- 
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-t...@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 disable a select?

2010-09-13 Thread Marnen Laibow-Koser
Fritz Trapper wrote:
> I want to use form template to render data for show.

Generally not a good idea from a UI point of view.  Just use plain text 
for display, unless you want to allow editing.

> 
> My idea is, to readonly/disable formelements. This works fine, except
> with selects. The following three variants of render code do not emit
> the keyword disabled to the html text:
> 
>f.select :attr, @choices, :include_blank => true,
>   :disabled => !...@condition
>f.select :attr, @choices, {:include_blank => true},
>   :disabled => !...@condition
>f.select :attr, @choices, {:include_blank => true},
>   {:disabled => !...@condition}
> 
> Writing readonly instead if disabled (which seems to be undefined for
> select) also doesn't have any effects.
> 
> What is going wrong?

Are you sure !...@condition is true when you expect it to be?

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-t...@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 3: finding a record by name in multilingual app

2010-09-13 Thread Heinz Strunk
What that not specific enough? I really don't know how to proceed right 
now cause there's no proper way to avoid name.

This is my latest approach which I don't like at all but well...
Page.find(Fixtures.identify(:welcome))
Works for every language but not so nice. Anyone else got a better 
solution?
-- 
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-t...@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: after_create not being called in seeds.rb?

2010-09-13 Thread Marnen Laibow-Koser
Please quote when replying; otherwise, it gets difficult to follow the 
discussion.

Heinz Strunk wrote:
> @Marnen: Actually they're not really users but NPCs which I need for 
> various things and I need a lot of them to populate the world.
> 
> Therefore it's not for test but to populate 

So this is actual production data?

> and I don't think factories 
> are good for so many objects, right?

Factories should be fine for creating so many objects -- but they're not 
for creating production data.

If it's production data, create it all and use seeds.
If it's test data, create only the few records you need and use 
factories.

[and, from earlier post]
> This works just fine and the users have been created after I ran
> db:seeds but what's not working is:
>
> after_create :write_comments
>
> protected
> def write_comments
>  comment = Comment.new
>  comment.text = "some text"
>  comment.user = self
>  comment.save!
> end

It's not appropriate to use an after_create for this sort of thing, I 
think.  In your 100.times block, just create a comment when you create 
each user.

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-t...@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: Re: onload and .html.erb

2010-09-13 Thread Abder-Rahman Ali
Thanks a lot everyone.
-- 
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-t...@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] How to disable a select?

2010-09-13 Thread Fritz Trapper
I want to use form template to render data for show.

My idea is, to readonly/disable formelements. This works fine, except
with selects. The following three variants of render code do not emit
the keyword disabled to the html text:

   f.select :attr, @choices, :include_blank => true,
  :disabled => !...@condition
   f.select :attr, @choices, {:include_blank => true},
  :disabled => !...@condition
   f.select :attr, @choices, {:include_blank => true},
  {:disabled => !...@condition}

Writing readonly instead if disabled (which seems to be undefined for
select) also doesn't have any effects.

What is going 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-t...@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: after_create not being called in seeds.rb?

2010-09-13 Thread Heinz Strunk
@brito: self always worked cause it's the instance of the current object 
which I wanna use so that should be fine.

@Marnen: Actually they're not really users but NPCs which I need for 
various things and I need a lot of them to populate the world.

Therefore it's not for test but to populate and I don't think factories 
are good for so many objects, right?
-- 
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-t...@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 I've missed in routes.rb?

2010-09-13 Thread Marnen Laibow-Koser
Msan Msan wrote:
> On 13 September 2010 16:02, radhames brito  wrote:
>> the default destroy route is
>> /controller/id , :method=> delete
>> {:action=>"destroy", :controller=>"sessions", :id=>"name.surname"}
>>
>> but your destroy action does not need an id really,
> 
> So I've to change the default destroy route for sessions resource?

Perhaps you should be using a singleton resource for sessions the way 
Authlogic does?

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-t...@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: Problems with the money gem

2010-09-13 Thread Marnen Laibow-Koser
Please quote when replying, otherwise the discussion becomes impossible 
to follow.

Jon Seidel wrote:
> I do have default values specified, but these only take effect when
> writing to the database, now when the new object is created.

Yes, of course.  If you need them before that, put them in the 
constructor.

(In other words: use Ruby's object model to your advantage! :) )

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-t...@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.



Re: [Rails] what I've missed in routes.rb?

2010-09-13 Thread Mauro
On 13 September 2010 16:02, radhames brito  wrote:
> the default destroy route is
> /controller/id , :method=> delete
> {:action=>"destroy", :controller=>"sessions", :id=>"name.surname"}
>
> but your destroy action does not need an id really,

So I've to change the default destroy route for sessions resource?

-- 
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-t...@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] redirect_to kills my session variable

2010-09-13 Thread Jim Burgess
Hi,

I'm trying to set a session variable in one action of
application_controller.rb, which is then accessed in a second action of
the same controller following a redirect.

Here's the code.

def cookie_test
  if cookies["cookie_test"].blank?
render :template => "shared/cookies_required"
  else
#redirect back to where the user came from
  end
end

protected

def cookies_required
  return true unless cookies["cookie_test"].blank?
  session[:return_to] = request.request_uri
  cookies["cookie_test"] = Time.now
  redirect_to :action => "cookie_test" and return false
end

The method 'cookies_required' is called first, which sets the session
variable 'session[:return_to]'.

I would like to be able to access this variable in the method
'cookie_test' following the redirect.

However, when I try to do so, it shows up as nil.

I tried replacing the session variable with a global variable and that
worked fine.
I also tried sending the 'request.request_uri' variable as a parameter
to the second action and that worked too.

But why is my session variable dying following the redirect??

Thanks in advance
-- 
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-t...@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.



Re: [Rails] Re: Rails Commenting, Plugins?

2010-09-13 Thread Michael Pavling
On 13 September 2010 13:36, radhames brito  wrote:
> "What does using AJAX or not have to do with whether or not you use a
> CAPTCHA process?"
>
> because some bots will bypass the captcha, and he will need a publishing
> page  where he can delete those spams that get through because captcha alone
> is not enough so at the end captcha is only an aid to stop most of the spam
> but not all.

Any bots that can bypass an AJAX captcha could bypass the same captcha
on a non-AJAX submission.
And AJAX or not, the choice is up to you whether to have a
"publishing/approval" page.

Again - There's nothing special about AJAX that makes any
implementation of a "commentable" feature inherently less secure. It's
*exactly* the same as a normal form submission/process procedure, just
performed by Javascript and in the background to the user.

-- 
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-t...@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: Problems with the money gem

2010-09-13 Thread JSeidel
I do have default values specified, but these only take effect when
writing to the database, now when the new object is created.

On Sep 13, 8:28 am, Marnen Laibow-Koser  wrote:
> Jon Seidel wrote:
> > I have a new app (Rails 2.3.8) that uses lots of money fields. I'm
> > using the money gem (3.0.5) and the acts_as_money plugin. I've written
> > a number of rspec model examples and everything seems to be working
> > fine there.
>
> > My problem is in defining forms for new & edit. As I've done in past
> > projects for complex layouts, I extracted the basic form to a partial
> > and include it in the new & edit views.
>
> > However, the model object is created and left with nulls in the
> > fields, and causes the money gem to complain with:
> >     "undefined method `subunit_to_unit' for nil:NilClass".
>
> > I thought I could use something like after_initialize() to hook into
> > the creation of a new object in Rails and set all the money attributes
> > to zero, but that didn't work (and several posts recommended against
> > that for performance reasons)...
>
> > Any suggestions on a clean way to hook my model object and make sure
> > it's got zeros for all the money values when the new object is
> > instantiated?
>
> Why not define a default value for the field on the DB side?  This has
> the added advantage of ensuring that there is no way to accidentally
> create a record without these values even if the Rails app is bypassed.
>
> Best,
> --
> Marnen Laibow-Koserhttp://www.maren.org
> mar...@marnen.org
> --
> 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-t...@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: after_create not being called in seeds.rb?

2010-09-13 Thread Marnen Laibow-Koser
Heinz Strunk wrote:
> Hello,
> 
> I'm using the seeds.rb to create some user records:
> 100.times do
>   user = User.new
>   user.username = Faker::Name.first_name
>   user.email = user.username+"@example.com"
>   user.save!
> end

This isn't directly a solution to your problem, but...

Is this for testing?  If so, I recommend using factories, not seeds. 
seeds.rb is for application seed data (such as tables of countries or 
shipping rates), not what you're apparently doing here.

...but why do your tests need 100 records to begin with?  Normally, you 
should just call the factory within each test to create the (1 or 2) 
records you need for that test.

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-t...@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: Problems with the money gem

2010-09-13 Thread Marnen Laibow-Koser
Jon Seidel wrote:
> I have a new app (Rails 2.3.8) that uses lots of money fields. I'm
> using the money gem (3.0.5) and the acts_as_money plugin. I've written
> a number of rspec model examples and everything seems to be working
> fine there.
> 
> My problem is in defining forms for new & edit. As I've done in past
> projects for complex layouts, I extracted the basic form to a partial
> and include it in the new & edit views.
> 
> However, the model object is created and left with nulls in the
> fields, and causes the money gem to complain with:
> "undefined method `subunit_to_unit' for nil:NilClass".
> 
> I thought I could use something like after_initialize() to hook into
> the creation of a new object in Rails and set all the money attributes
> to zero, but that didn't work (and several posts recommended against
> that for performance reasons)...
> 
> Any suggestions on a clean way to hook my model object and make sure
> it's got zeros for all the money values when the new object is
> instantiated?

Why not define a default value for the field on the DB side?  This has 
the added advantage of ensuring that there is no way to accidentally 
create a record without these values even if the Rails app is bypassed.

Best,
--
Marnen Laibow-Koser
http://www.maren.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-t...@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: REST perhaps I don't undestand it.

2010-09-13 Thread Sandy


On Sep 10, 1:58 pm, Marnen Laibow-Koser  wrote:
> Msan Msan wrote:
> > On 10 September 2010 15:40, Sandy  wrote:
> >>> > session[:user = nil
>
> >> There appear to be several typos:
>
> >> session[:user = nil
> >> should be:
> >> session[:user = nil] (missing ])
>
> > Or should be session[:user] = nil
> > Is that the same?
>
> No, Sandy was in error.

Marmen was correct.  The missing ] belonged where he showed it.  Sorry
about any confusion.

>
> Best,
> --
> Marnen Laibow-Koserhttp://www.marnen.org
> mar...@marnen.org
> --
> 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-t...@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] Problems with the money gem

2010-09-13 Thread JSeidel
I have a new app (Rails 2.3.8) that uses lots of money fields. I'm
using the money gem (3.0.5) and the acts_as_money plugin. I've written
a number of rspec model examples and everything seems to be working
fine there.

My problem is in defining forms for new & edit. As I've done in past
projects for complex layouts, I extracted the basic form to a partial
and include it in the new & edit views.

However, the model object is created and left with nulls in the
fields, and causes the money gem to complain with:
"undefined method `subunit_to_unit' for nil:NilClass".

I thought I could use something like after_initialize() to hook into
the creation of a new object in Rails and set all the money attributes
to zero, but that didn't work (and several posts recommended against
that for performance reasons)...

Any suggestions on a clean way to hook my model object and make sure
it's got zeros for all the money values when the new object is
instantiated?

-- 
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-t...@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: X Modek object into Y controller

2010-09-13 Thread Awijeet Mr.
Awijeet Mr. wrote:
> How to use x.new() in y_controller.rb where x is model and y is
> controller?
> 
> Thanks

Thanks got the solution.
-- 
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-t...@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.



Re: [Rails] X Modek object into Y controller

2010-09-13 Thread Adam
On Mon, Sep 13, 2010 at 10:01 AM, Awijeet Mr.  wrote:

> How to use x.new() in y_controller.rb where x is model and y is
> controller?
>
> Thanks


Nothing to it, just type
> X.new
like you said. What trouble are you having?

-- 
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-t...@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] X Modek object into Y controller

2010-09-13 Thread Awijeet Mr.
How to use x.new() in y_controller.rb where x is model and y is
controller?

Thanks
-- 
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-t...@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.



Re: [Rails] Re: Re: Re: Rails 3 render partial

2010-09-13 Thread radhames brito
change this
render :partial =>'sth',:object => @sth

to this , and call the array in the controller like this @sths
then create a partial with the singular , _sth.html.erb

 render :partial =>@sths


i always do it that way and works perfectly


On Mon, Sep 13, 2010 at 10:23 AM, Zhuhao Wang  wrote:

> radhames brito wrote:
> > What was the problem? how did you solve it?
>
> render :partial =>'sth',:object => @sth
>
> is not working in rails 3,it pass the first element of the array
> @sth(I'm not sure what would happen if @sth is not an array),thus you
> can't call each in the template.You have to use :locals =>{:sth
> =>@sth}.Seems a little complicated,is it a bug or some change not
> mentioned in the changelog?
>
> Before I realize this I changed the view a little,added <%= Tutor.each
> .%>,and got that text.
> --
> 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-t...@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.
>
>

-- 
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-t...@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: Re: STI and nested object on subclass

2010-09-13 Thread Marnen Laibow-Koser
[Please quote when replying.  Otherwise the discussion is impossible to 
follow.]

Javier Ruiz wrote:
> Yep that's finally how I will have to do it... but this is not what I
> wanted. A has_one relation means that I have to access things like:
> 
> Anotherclass.property
> Anotherclass.childclass.specific_property
> Anotherclass.childclass.parentclass.common_property

That makes sense from a relational point of view.  If you don't like it, 
then use STI.

> 
> And more important... I need to manually manage related objects (or
> create hooks os similar). I mean I need for example to do something
> like:
> 
> a = Anotherclass.new
> b = Childclass.new
> a.childclass = b
> 
> ... and so on...

You'd need to do that regardless of whether your original idea worked.

> 
> I was thinking "rails' magic" was really magic ;-)

I suppose it is, but it doesn't extend to spreading one class across 
multiple tables.

If you were ambitious, you probably *could* extend ActiveRecord to do 
that, but I'm not sure it's a good idea -- it's trying to impose too 
much of an OO approach on a relational DB.  Alternatively, you could try 
an OODB like GemStone/MagLev.

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-t...@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.



Re: [Rails] Re: onload and .html.erb

2010-09-13 Thread radhames brito
You should use s javascript librery other wise it will take you ages to make
something practical and even more time to make your code work on all
browsers.

javascript libreries lets you do thigns like  client side validation, date
picker, inline editing, autocomplete, slider, drag and drop, sorting
tooltips, progress bar
ajax.  In other words make your site fell like a desktop application

http://jqueryui.com/

http://mootools.net/

http://www.dojotoolkit.org/





On Mon, Sep 13, 2010 at 9:38 AM, Marnen Laibow-Koser
wrote:

> Frederick Cheung wrote:
> > On Sep 12, 11:48�pm, Abder-Rahman Ali  wrote:
> >
> >> As you know, if I want to run the Javascript code on loading the page, I
> >> use 
> >>
> >> How can I do that in my "show.html.erb" file? Since I don't have a body
> >> tag?
> >>
> >
> > If I were you I'd have a separate js file with something like
> > document.observe('dom:loaded', ...) or $(document).ready that invokes
> > your javascript
> >
>
> Agreed.   is risky as well as not being unobtrusive.
>
> > Fred
>
> 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-t...@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.
>
>

-- 
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-t...@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] Intelligent Searchform

2010-09-13 Thread Hans Hartmann
Hi there,

i wrote an intelligent searchform, which is divided into categories.
Just a short overview of the workflow. For every keyword, which is
entered in the searchform the matches are checked. So we've got a rank
in a hash.

[key of entry, relevance match]

For example:
@hash = [123 => 5, 124 =>2, 125 => 5, 126 => 1, etc...]

I ordered the Hash "by relevance" simply by ordering by the hash values:
@hash.sort_by {|a,b| b})

@hash = [123 => 5, 125 => 5, 124 =>2, 126 => 1, etc...]

No I want to find my entries by the key values of the hash.

Thats not the problem:
@entries = Entry.find(@hash)
or
@entries = Entry.find(@hash.keys)

The problem is, that the entries are (by standard) ordered by ID and not
in order by the Hash-Keys I passed.
Is there a possibility to order by my "relevance system" (even if there
isn't a coloumn in the Entries-Table.

Thank you 'till now
Hans
-- 
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-t...@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: Re: Re: Rails 3 render partial

2010-09-13 Thread Zhuhao Wang
radhames brito wrote:
> What was the problem? how did you solve it?

render :partial =>'sth',:object => @sth

is not working in rails 3,it pass the first element of the array 
@sth(I'm not sure what would happen if @sth is not an array),thus you 
can't call each in the template.You have to use :locals =>{:sth 
=>@sth}.Seems a little complicated,is it a bug or some change not 
mentioned in the changelog?

Before I realize this I changed the view a little,added <%= Tutor.each 
.%>,and got that text.
-- 
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-t...@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: Re: Rails 3 render partial

2010-09-13 Thread Bharat Ruparel
Hello,
You are right about the object deprecation in Rails 3.  I solved the 
problem the same way you did.  Instead of passing the table name in 
object.  I now pass it in the locals hash.
Hope this helps.
Bharat
-- 
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-t...@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.



Re: [Rails] Re: STI and nested object on subclass

2010-09-13 Thread Javier Ruiz
Yep that's finally how I will have to do it... but this is not what I
wanted. A has_one relation means that I have to access things like:

Anotherclass.property
Anotherclass.childclass.specific_property
Anotherclass.childclass.parentclass.common_property

And more important... I need to manually manage related objects (or
create hooks os similar). I mean I need for example to do something
like:

a = Anotherclass.new
b = Childclass.new
a.childclass = b

... and so on...

I was thinking "rails' magic" was really magic ;-)
 

On Mon, 2010-09-13 at 16:06 +0200, Marnen Laibow-Koser wrote:
> jruiz wrote:
> > Well I really wanted to have inheritance on activerecord based classes
> > (with db tables saving common data in base class and concrete data in
> > subclasses). Sad to know rails can't do it. I'll try to do what I need
> > with a different logic.
> 
> You can do that with a has_one relationship.
> 
> > 
> > Thanks a lot for your help Fred :-)
> 
> 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-t...@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.



Re: [Rails] Re: Re: Rails 3 render partial

2010-09-13 Thread radhames brito
What was the problem? how did you solve it?

On Mon, Sep 13, 2010 at 10:12 AM, radhames brito  wrote:

> surely, got confused there.
>
>
> On Mon, Sep 13, 2010 at 10:08 AM, Zhuhao Wang wrote:
>
>> radhames brito wrote:
>> > those are the classes you are forgeting to call a property in the view,
>> >
>> >
>> > seems like you are doing this
>> >
>> > <%= @tutors.each do |tutor|%>
>> > <%= tutor%>
>> >
>> > it should be
>> >
>> > <%= @tutors.each do |tutor|%>
>> > <%= tutor.name %>
>>
>> I tried,
>>
>> <%= @tutors.each do |tutor|%>
>>
>> this line should be
>>
>> <% @tutors.each do |tutor|%>
>>
>> fix this,thx
>>
>>
>> I also find an artical
>> http://darwinweb.net/articles/getting-up-to-speed-with-rails-3 says
>> :object is removed,but you can find an offcial artical here
>> http://edgeguides.rubyonrails.org/layouts_and_rendering.html which says
>> :object is still what I expect...
>>
>> --
>> 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-t...@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.
>>
>>
>

-- 
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-t...@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.



Re: [Rails] Re: Re: Rails 3 render partial

2010-09-13 Thread radhames brito
surely, got confused there.

On Mon, Sep 13, 2010 at 10:08 AM, Zhuhao Wang  wrote:

> radhames brito wrote:
> > those are the classes you are forgeting to call a property in the view,
> >
> >
> > seems like you are doing this
> >
> > <%= @tutors.each do |tutor|%>
> > <%= tutor%>
> >
> > it should be
> >
> > <%= @tutors.each do |tutor|%>
> > <%= tutor.name %>
>
> I tried,
>
> <%= @tutors.each do |tutor|%>
>
> this line should be
>
> <% @tutors.each do |tutor|%>
>
> fix this,thx
>
>
> I also find an artical
> http://darwinweb.net/articles/getting-up-to-speed-with-rails-3 says
> :object is removed,but you can find an offcial artical here
> http://edgeguides.rubyonrails.org/layouts_and_rendering.html which says
> :object is still what I expect...
>
> --
> 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-t...@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.
>
>

-- 
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-t...@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: Read data in JSON format

2010-09-13 Thread Marnen Laibow-Koser
Ahmed Abdelsalam wrote:
> Hi,
> 
> I have some data stored in file in JSON format. I'd like to read these
> data and store them into database in rail application. Is there any
> plugin to perform this? or direct code?
> 

ActiveSupport has some JSON stuff built in.  Check the docs for 
ActiveSupport::JSON.


> Should I convert this data to csv or other format?

Either leave it in JSON or use YAML (which is *almost* a superset of 
JSON).

> 
> Thanks,
> 
> Ahmed

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-t...@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.



Re: [Rails] View and Controllers association

2010-09-13 Thread radhames brito
Post (singular with capital) is the model

On Mon, Sep 13, 2010 at 9:02 AM, Felix Schäfer wrote:

>
> Am 13.09.2010 um 14:58 schrieb Awijeet Mr.:
>
> > if  I write i.class it returns Post, so I thought module will be a
> > method in post_controller.rb. But it's not
>
> If i is of the type Post, i.module will call the method module from the
> Post object in app/models/post.rb, not from a PostsController object as you
> seem to think it will.
>
> 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-t...@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.
>
>

-- 
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-t...@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: Re: Rails 3 render partial

2010-09-13 Thread Zhuhao Wang
radhames brito wrote:
> those are the classes you are forgeting to call a property in the view,
> 
> 
> seems like you are doing this
> 
> <%= @tutors.each do |tutor|%>
> <%= tutor%>
> 
> it should be
> 
> <%= @tutors.each do |tutor|%>
> <%= tutor.name %>

I tried,

<%= @tutors.each do |tutor|%>

this line should be

<% @tutors.each do |tutor|%>

fix this,thx


I also find an artical 
http://darwinweb.net/articles/getting-up-to-speed-with-rails-3 says 
:object is removed,but you can find an offcial artical here 
http://edgeguides.rubyonrails.org/layouts_and_rendering.html which says 
:object is still what I expect...

-- 
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-t...@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: STI and nested object on subclass

2010-09-13 Thread Marnen Laibow-Koser
jruiz wrote:
> Well I really wanted to have inheritance on activerecord based classes
> (with db tables saving common data in base class and concrete data in
> subclasses). Sad to know rails can't do it. I'll try to do what I need
> with a different logic.

You can do that with a has_one relationship.

> 
> Thanks a lot for your help Fred :-)

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-t...@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.



Re: [Rails] what I've missed in routes.rb?

2010-09-13 Thread radhames brito
the default destroy route is
/controller/id , :method=> delete
{:action=>"destroy", :controller=>"sessions", :id=>"name.surname"}

but your destroy action does not need an id really,
the other problem is that you dont need an id but pass

session_path(session[:cas_user])

 and then not use it becuase you do this

session[:id] = nil

im not user if yo want to do this

session[:cas_user] = nil



On Mon, Sep 13, 2010 at 9:54 AM, radhames brito  wrote:

> you dont need to pass this session[:cas_user]
>
>
>
> On Mon, Sep 13, 2010 at 7:53 AM, Mauro  wrote:
>
>> In routes.rb I've put:
>>
>> resources :sessions
>>
>> controller is:
>>
>> class SessionsController < ApplicationController
>>
>>  def destroy
>>   session[:id] = nil
>>   session.delete(:casfilteruser)
>>   CASClient::Frameworks::Rails::Filter.logout(self)
>>  end
>>
>> end
>>
>> In application.html.erb I have:
>>
>> <%= link_to 'Logout', session_path(session[:cas_user]), :method => :delete
>> %>
>>
>> I think it's all but:
>>
>> No route matches {:action=>"destroy", :controller=>"sessions",
>> :id=>"name.surname"}
>>
>> What I've missed?
>>
>> --
>> 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-t...@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.
>>
>>
>

-- 
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-t...@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: STI and nested object on subclass

2010-09-13 Thread jruiz
Well I really wanted to have inheritance on activerecord based classes
(with db tables saving common data in base class and concrete data in
subclasses). Sad to know rails can't do it. I'll try to do what I need
with a different logic.

Thanks a lot for your help Fred :-)


On Sep 13, 2:32 pm, Frederick Cheung 
wrote:
> On Sep 13, 11:15 am, Javier Ruiz  wrote:
>
> > Ok, then maybe I didn't ask properly... you are right it's not STI what
> > I'm trying to do, but I'll try to explain it better.
>
> > What I need is just to extend a base class (wich is a model with its db
> > table and all activerecord logic) with another class (a subclass with
> > its own table and all activerecord logic, plus the parent methods,
> > properties and so on). I tried to do it like I mentioned in my first
> > email, but when the child class (the extended class) has a fk to another
> > table, rails tries to find the fk in the parent class, not in the
> > extended class, like the example I posted before:
>
> Rails doesn't do that - either the parent class is abstract (ie has no
> table) or you get STI. You might have better look putting the common
> functionality in a module, or having an abstract class which is the
> parent of your 2 concrete classes.
>
> Fred

-- 
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-t...@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.



Re: [Rails] what I've missed in routes.rb?

2010-09-13 Thread radhames brito
you dont need to pass this session[:cas_user]


On Mon, Sep 13, 2010 at 7:53 AM, Mauro  wrote:

> In routes.rb I've put:
>
> resources :sessions
>
> controller is:
>
> class SessionsController < ApplicationController
>
>  def destroy
>   session[:id] = nil
>   session.delete(:casfilteruser)
>   CASClient::Frameworks::Rails::Filter.logout(self)
>  end
>
> end
>
> In application.html.erb I have:
>
> <%= link_to 'Logout', session_path(session[:cas_user]), :method => :delete
> %>
>
> I think it's all but:
>
> No route matches {:action=>"destroy", :controller=>"sessions",
> :id=>"name.surname"}
>
> What I've missed?
>
> --
> 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-t...@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.
>
>

-- 
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-t...@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.



Re: [Rails] Re: Rails 3 render partial

2010-09-13 Thread radhames brito
those are the classes you are forgeting to call a property in the view,


seems like you are doing this

<%= @tutors.each do |tutor|%>
<%= tutor%>

it should be

<%= @tutors.each do |tutor|%>
<%= tutor.name %>



On Mon, Sep 13, 2010 at 6:14 AM, Zhuhao Wang  wrote:

> Zhuhao Wang wrote:
> > Bharat Ruparel wrote:
> >> The following rails 2.3.x code is not working in rails 3 beta 4:
> >>
> >>   def
> >>
> render_crud_table(obj,controller_name,columns,search_fields_array,status_array,actions)
> >> render :partial => 'shared/crud_maint_table', :object => obj,
> >>  :locals => {:controller_name => controller_name, :columns =>
> >> columns, :search_fields_array => search_fields_array, :status_array =>
> >> status_array, :actions => actions}
> >>   end
> >>
> >> The partial _crud_maint_table in the shared folder has this code
> >> snippet:
> >>
> >> ...
> >>   - crud_maint_table.each do |a_rec|
> >> %tr{ :class => cycle("odd","even") }
> >>   - columns.each_with_index do |col, i|
> >> %td{ :class => (i == 0 ? 'first' : nil) }
> >> ...
> >>
> >> See the crud_maint_table.each loop?  That works in rails 2.3.x but not
> >> in rails 3.
> >> Please advise.
> >> thanks.
> >> Bharat
> >
> >
> > Well,I met the same problem.
> > I had some debug, it seems that rails treat :object as :collection, so
> > the crud_maint_table actually is the first element of the array obj.
> > I'm not sure it's a bug or sth changed since 3 and I haven't found any
> > solution
>
> When I tried to use :locals, there are some strange text:
>
>
> ###
>
> before the content of the partial ,seems like the ID of the elements of
> the array I passed in...can't get rid of it.
> --
> 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-t...@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.
>
>

-- 
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-t...@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.



  1   2   >