[Rails] Re: Validate field not in model?

2009-02-27 Thread Mike C

Nevermind, getter was returning a user object instead of a string.
fixed. :)

On Feb 26, 10:10 pm, Mike C snib...@gmail.com wrote:
 Ok, I did it. But in the model I have validates_presence_of, and even
 though the field is filled, I keep getting the blank error.

 On Feb 26, 9:52 pm, CFC zuso...@gmail.com wrote:

  define it as a getter and setter.

  On Fri, Feb 27, 2009 at 10:49 AM, Mike C snib...@gmail.com wrote:

   I want to validate a field in my form that's not an attribute in the
   model. How do I do this?

  --
  TWRUG Blog:http://blog.rubyonrails.org.tw

  CFC on Rails:http://zusocfc.blogspot.com

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



[Rails] Getting unique entries from models?

2009-02-27 Thread Mike C

I'm using acts_as_taggable_on and I want to get a list of unique
taggings. How can I do this? In a more general sense, say that I have
a Product model with attributes name and price. I have these:

id: 1
Name: Juice
Price: 5

id: 2
Name: Juice
Price: 5

So when I do a Product.find(:all) I'll get both, but I only want one.
How can I do this so that no matter now many duplicates there are,
I'll only get one PLUS all the other UNIQUE products?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Validate field not in model?

2009-02-27 Thread Nilesh Kumar
Hi Mike. Can you share the code snippet for the getter and setter methods
you used,  thanks.





On Fri, Feb 27, 2009 at 1:48 PM, Mike C snib...@gmail.com wrote:


 Nevermind, getter was returning a user object instead of a string.
 fixed. :)

 On Feb 26, 10:10 pm, Mike C snib...@gmail.com wrote:
  Ok, I did it. But in the model I have validates_presence_of, and even
  though the field is filled, I keep getting the blank error.
 
  On Feb 26, 9:52 pm, CFC zuso...@gmail.com wrote:
 
   define it as a getter and setter.
 
   On Fri, Feb 27, 2009 at 10:49 AM, Mike C snib...@gmail.com wrote:
 
I want to validate a field in my form that's not an attribute in the
model. How do I do this?
 
   --
   TWRUG Blog:http://blog.rubyonrails.org.tw
 
   CFC on Rails:http://zusocfc.blogspot.com
 
   Only two surfaces of a box:http://blog.pixnet.net/zusocfc
 


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



[Rails] Actionwebservice for rails2.2.2 / ruby 1.8.7

2009-02-27 Thread Lin Wj

has anyone gotten action actionwebservice to work for this config ?

tried instructions from
http://www.texperts.com/2007/12/21/using-action-web-service-with-rails-20/

and got a activate': can't activate actionpack   on server startup
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] content

2009-02-27 Thread madhavi.k

hello all,

how to do content moderation,content authentication and content
approval for rails application ?

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



[Rails] Re: i18n with Rails 2.1

2009-02-27 Thread Jeba Momin

Jeba Momin wrote:
 MaD wrote:
 try specifying the source:
   gem update rails --source=http://gems.rubyforge.org
 
 other than that try to update your rubygems.
 
Hey...I'm trying to update rails on another m/c now...and I'm getting 
the same error as before:


C:\Front Endgem update rails --source=http://gems.rubyforge.org
Updating installed gems
Updating rails
ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
bad response ( The request is not supported.  ) 500 
(http://gems.rubyforge.v
m.bytemark.co.uk/gems/actionmailer-2.2.2.gem)


Please can someone tell me..where am I going wrong
Thank 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-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Rails 2.2 + Apache 2.2 + RewriteBase /app = broken

2009-02-27 Thread Ari

I'm trying to run a rails app under an alias like this:

Alias /app /var/www/railsapp/public
RewriteBase /app
...

I am using the same configuration that has worked for the app under
Rails 1, but since I upgraded it to the latest version I get:


The page you were looking for doesn't exist.

You may have mistyped the address or the page may have moved.


In the application log, I find that it is looking for routes with /app
at the beginning even though RewriteBase was supposed to take care of
that.  What am I missing?  How can I make my app happy again?  Full
source code is here:

https://assembly.cornell.edu/trac.fcgi/cicero

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



[Rails] Problem with select_tag

2009-02-27 Thread pleb...@gmail.com

i create drop-down memu for organelle by using select_tag but problem
is
 can't get value for form select_tag to database seqfeature but
form.text_field ,it's work  , i don't understand
 why? pls help me
##
 code for veiw.rhtm:
 % form_for :seqfeature do |form| %
  div class=form_row
label for=seq_nameSequence Name :/label
%= form.text_field :seq_name %
  /div

  div class=form_row
label for=organelleOrganelle /label
%= select_tag organelle , options_for_select([,
mitochondrion, nucleomorph, plastid, mitochondrion:
kinetoplast,
plastid: chloroplast, plastid: apicoplast, plastid:
chromoplast,
plastid: cyanelle, plastid: leucoplast, plastid:
protoplastid ])
%
  /div
%= submit_tag Submit !, :class = submit %
% end %
 

code for submit controller:

class SubmitController  ApplicationController
  def view
if request.post? and params[:seqfeature]
  @seqfeature = Seqfeature.new(params[:seqfeature])
  if @seqfeature.save
render :text = sequence submitted
  end
end
  end
end
 # the vale from form insert to  table seqfeatures but i can't
get
value

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



[Rails] Using form_for and has_many associations with a controller in its own subdirectory

2009-02-27 Thread Matt W.

Hi,

I'm trying to create a Blog in it's own subdirectory for an E-commerce
site. Everything is hooked up just fine for the basic posting, but
when I try to add Comments, I'm getting all sorts of headaches! I'm
referring to the screencast by Ryan Bates on the rubyonrails.org site.

Basically, my controller is Blog::Comments, in my Blog::Post comment
form I have this line:

% form_for [...@post, Blog::Comment.new] do |f| %

Which throws this error:

undefined method `blog_post_blog_comments_path' for #ActionView::Base:
0x25ad3fc

The path that I think I need is 'blog_post_comments_path, and I'm not
sure if this is a routing issue or something else?

Or, if I try this line:

% form_for [...@post, :Comment.new] do |f| %

I get this error:

uninitialized constant ActionView::Base::CompiledTemplates::Comment

I'm guessing it  couldn't find the Comment Controller because it is
actually Blog::Comment

Currently, I have this in my routes file:

  map.namespace :blog do |blog|
blog.resources :posts, :has_many = :comments
  end

Any advice would be greatly appreciated, thanks!

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



[Rails] Re: Actionwebservice for rails2.2.2 / ruby 1.8.7

2009-02-27 Thread Frederick Cheung



On Feb 27, 9:07 am, Lin Wj rails-mailing-l...@andreas-s.net wrote:
 has anyone gotten action actionwebservice to work for this config ?

 tried instructions 
 fromhttp://www.texperts.com/2007/12/21/using-action-web-service-with-rail...

 and got a activate': can't activate actionpack   on server startup

That's almost what I use (i doubt ruby 1.8.6 versus 1.8.7) and those
instructions work for me (I wrote them :-))

The key thing is to freeze all of rails. You might also want to have a
look at the datanoise-actionwebservice gem.

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



[Rails] Re: Modify beginning_of_week?

2009-02-27 Thread Gavin

What's the argument that you're passing the method?

Just an integer?

On Feb 27, 12:58 am, Guillaume Loader rails-mailing-l...@andreas-
s.net wrote:
 Hello everyone!

 Is it possible to modify this function: beginning_of_week?

 What I want is something like this :
 beginning_of_week(0) returns Sunday
 beginning_of_week(1) returns Monday

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



[Rails] Re: rake bombs on openssl (on Ubuntu)

2009-02-27 Thread Frederick Cheung



On Feb 27, 1:55 am, Phor Gruber phorgru...@gmail.com wrote:
 To me,
 It looks like openssl.rb is missing somewhere.

 I assume it should be under /rho which is where I installed ruby.

 I'm on ubuntu-linux and I do see openssl development packages inside
 of my OS:

 $ apt-cache search libssl

Doesn't that just search for the package in your cached list of
package descriptions (rather than installed packages)

Fred

 cl-plus-ssl - A simple Common Lisp interface to OpenSSL
 dcmtk - The OFFIS DICOM toolkit command line utilities
 libdcmtk1 - The OFFIS DICOM toolkit runtime libraries
 libdcmtk1-dev - The OFFIS DICOM toolkit development libraries and
 headers
 libssl-ocaml - OCaml bindings for OpenSSL
 libssl-ocaml-dev - OCaml bindings for OpenSSL
 libssl-dev - SSL development libraries, header files and documentation
 libssl0.9.8 - SSL shared libraries
 libssl0.9.8-dbg - Symbol tables for libssl and libcrypto

 Also, I see this:

 $ apt-cache search  libopenssl-ruby
 libopenssl-ruby - OpenSSL interface for Ruby
 libopenssl-ruby1.9 - OpenSSL interface for Ruby 1.9
 ruby1.8 - Interpreter of object-oriented scripting language Ruby 1.8
 libopenssl-ruby1.8 - OpenSSL interface for Ruby 1.8

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



[Rails] Re: authentication and user management questions

2009-02-27 Thread MaD

at least that token-problem is solved.

but it's still weird, cause that session_expiry code is actually
working on one of my apps. are you sure you don't have some sort of
typo? (sth. like  instead of ) i would debug that piece of code to
see, why the session is reset.
btw: 1800 sec is of course half an hour (not what my comment stated)
*g*




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



[Rails] Re: i18n with Rails 2.1

2009-02-27 Thread MaD

http://gems.rubyforge.vm.bytemark.co.uk/gems/actionmailer-2.2.2.gem

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



[Rails] Re: i18n with Rails 2.1

2009-02-27 Thread Jeba Momin

MaD wrote:
 http://gems.rubyforge.vm.bytemark.co.uk/gems/actionmailer-2.2.2.gem
 
 that address seems to be working. have you tried it again?

Hey...
It worked when I did this:
C:\gem update rails --source=http://gems.rubyforge.org

'Front End' is my Rails application...
When I try doing gem update from within my rails application...only then 
I get the error...!!!
Anyways...
Thanks a lot for your help..
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: Problem with select_tag

2009-02-27 Thread vimal

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



[Rails] Re: Problem with select_tag

2009-02-27 Thread Thiti Panya

vimal wrote:
 i guess the select tag should be represented as form.select_tag

thank a lot but i used it , i have error this this


undefined method `select_tag' for 
#ActionView::Helpers::FormBuilder:0xb788a2a4
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] blacklist

2009-02-27 Thread madhavi.k


hello all,

I installed blacklist plugin from the link
 http://github.com/watsonian/blacklist/tree/master.

when start the server I am getting  as below :

C:\Documents and Settings\Madhavi\Desktop\madhavi_moments
\madhavi_momentsruby script/server
= Booting WEBrick...
c:/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/servers/
webrick.rb:13: w
arning: already initialized constant OPTIONS
= Booting WEBrick...
c:/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/servers/
webrick.rb:13: w
arning: already initialized constant OPTIONS
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`gem_original_re
quire': no such file to load -- RedCloth (MissingSourceFile)
from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
27:in `re
quire'
from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/
active_suppo
rt/dependencies.rb:496:in `require'
from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/
active_suppo
rt/dependencies.rb:342:in `new_constants_in'
from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/
active_suppo
rt/dependencies.rb:496:in `require'
from C:/Documents and Settings/Madhavi/Desktop/madhavi_moments/
madhavi_m
oments/vendor/plugins/watsonian-blacklist/watsonian-blacklist/lib/
black_list.rb:
31
from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
27:in `ge
m_original_require'
from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
27:in `re
quire'
from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/
active_suppo
rt/dependencies.rb:496:in `require'
 ... 26 levels...
from c:/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/
server.rb:3
9
from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
32:in `ge
m_original_require'
from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
32:in `re
quire'
from script/server:3

C:\Documents and Settings\Madhavi\Desktop\madhavi_moments
\madhavi_moments



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



[Rails] Re: Problem with select_tag

2009-02-27 Thread vimal

use it as a symbol :organelle rather than as a string organelle
make sure the :organelle field is made available in ur model seqfeature
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: blacklist

2009-02-27 Thread vimal

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



[Rails] Re: delete all with has_many

2009-02-27 Thread Maurício Linhares

@appt_to_edit.appt_edits.destroy_all

-
Maurício Linhares
http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en)



On Fri, Feb 27, 2009 at 3:58 AM, David dly...@gmail.com wrote:

 Im not sure using :dependent = delete_all is correct here but I want
 to delete all the ApptEdits when an Appointment is updated in a
 certain situation.  so i have:

 @appt_to_edit.update_attributes(appointment_info)

 and then i want to do something like:

 @appt_to_edit.appt_edits.destroy

 but this does not work.  i was thinking about something like
 using :dependent = :delete_all, but i only want to do this after a
 specific update_attributes call and not every one so i dont think this
 is appropriate.  what is the best way to write the equivalent to the
 pseudocode: @appt_to_edit.appt_edits.destroy?




 


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



[Rails] Re: blacklist

2009-02-27 Thread madhavi.k

Thank u

But I couldnt fink the link for   Redcloth plugin .
can u suggest a link for that.

On Feb 27, 3:51 pm, vimal cool.vimalsm...@gmail.com wrote:
 install the RedCloth plugin using gem
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: blacklist

2009-02-27 Thread vimal


whenever u r unfamiliar with the gem
try:

gem search RedCloth --remote

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



[Rails] Q: find :include

2009-02-27 Thread rails.n...@gmail.com

So I have

  class Post  ActiveRecord::Base
belongs_to :user
  end

  @posts = Post.find :all, :include=:user

 but when I look at my logs I see this:

  Post Load (2.4ms)   SELECT * FROM `posts`
  User Load (0.2ms)   SELECT * FROM `users` WHERE (`users`.`id` = 1)

I was expecting one combined SQL statement?

Any ideas?
thanks :)





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



[Rails] Re: Q: find :include

2009-02-27 Thread Frederick Cheung


On 27 Feb 2009, at 11:26, rails.n...@gmail.com wrote:


 So I have

  class Post  ActiveRecord::Base
belongs_to :user
  end

  @posts = Post.find :all, :include=:user

  but when I look at my logs I see this:

  Post Load (2.4ms)   SELECT * FROM `posts`
  User Load (0.2ms)   SELECT * FROM `users` WHERE (`users`.`id` = 1)

 I was expecting one combined SQL statement?

Not since rails 2.1

Fred
 Any ideas?
 thanks :)





 


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



[Rails] simple select

2009-02-27 Thread Petan Cert

Hi all,

I have two models gallery and photo (has_many - belongs_to).
Can I use this to find the primary photo for the given gallery?

@gallery = @user.galleries
@primary_photo = @gallery.photos.find_by_primary(true).first

it ends with error.

Thanks for any help.
P.
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: Q: find :include

2009-02-27 Thread vimal

what exactly do you want to do???

for me it looks like you want all the posts for the particular user
then it should be @posts = User.posts
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: simple select

2009-02-27 Thread Frederick Cheung


On 27 Feb 2009, at 11:31, Petan Cert wrote:


 Hi all,

 I have two models gallery and photo (has_many - belongs_to).
 Can I use this to find the primary photo for the given gallery?

 @gallery = @user.galleries
 @primary_photo = @gallery.photos.find_by_primary(true).first


find_by_xxx returns a single object (or nil) so that call to first is  
superfluous.

Fred
 it ends with error.

 Thanks for any help.
 P.
 -- 
 Posted via http://www.ruby-forum.com/.

 


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



[Rails] Re: simple select

2009-02-27 Thread MaD

the correct call is:
@primary_photo = @gallery.photos.find(:first, :conditions = {:primary
= true})

or (but thats an old one and i don't know if that isn't deprecated):
@primary_photo = @gallery.photos.find_first_by_primary(true)

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



[Rails] Re: simple select

2009-02-27 Thread MaD

or you could add a named_scope to your photo-model:
  named_scope :primary, :conditions = { :primary = true }

then your call could be like:
  @primary_photo = @gallery.photos.primary.first

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



[Rails] Re: form_remote_tag

2009-02-27 Thread Adam Akhtar

can anyone help?:
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: blacklist

2009-02-27 Thread madhavi.k


I installed Recloth successfully...
Im following this link : http://github.com/watsonian/blacklist/tree/master
for blacklist words...

Is it necessary to write code in my application beyond this
installation ???
If so guide me.

Can any body help me out?

Thank you

On Feb 27, 4:22 pm, vimal cool.vimalsm...@gmail.com wrote:
 whenever u r unfamiliar with the gem
 try:

 gem search RedCloth --remote

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



[Rails] Re: form_remote_tag

2009-02-27 Thread vimal


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



[Rails] Re: blacklist

2009-02-27 Thread vimal


I haven't used blacklist either
I just traced the error in ur code
---
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`gem_original_require': no such file to load -- RedCloth
(MissingSourceFile)
from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/
custom_require.rb:
27:in

I guess the blacklist gem needs RedCloth(a dependency) too

Just try to restart the server and check for errors.i think there wont
be any other additional code
Try to get the follow through in the Blacklist documentation correct

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



[Rails] Re: Problem with select_tag

2009-02-27 Thread Sijo Kg

change like

%= form.select :organelle, ([,
mitochondrion, nucleomorph, plastid, mitochondrion:
kinetoplast,
plastid: chloroplast, plastid: apicoplast, plastid:
chromoplast,
plastid: cyanelle, plastid: leucoplast, plastid:
protoplastid ])
%

 and it will submit to the create action of seqfeature controller. 
.There you can write the code as in def view

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

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



[Rails] has_many :through relationship in polymorphic associations

2009-02-27 Thread Preethi Sivakumar

Hi,
I'm facing an issue in polymorphic associations when i try to to
:through relationship.
I've three models:profile,gbluser,community

profile.rb
-
  belongs_to :node ,:polymorphic = true
  belongs_to :community,:class_name = community,
:foreign_key = node_id,
:conditions = node_type = 'community'
  belongs_to :gblorganization,:class_name = gblorganization,
:foreign_key = node_id,
:conditions = node_type = 'gblorganization'
  has_and_belongs_to_many :gblusers

Vcgbluser.rb

has_many :communities,,:through=:profiles,:conditions =
profiles.node_type = 'Community',:source=:community

Vccommunity.rb
--
has_many :gblusers ,:class_name
=gbluser,:through=:profiles,:conditions = profiles.node_type =
'Community',:source=:community

I'm trying to implement has_many :through relationship between community
and users.
user has_many communities through profiles and
communities has_many users through profiles

When i'm trying to do @user.communities, the search is made not on the
mapping table between user and profiles but on the profile table itself.
Rails is searching for user_id in profiles table but i've
has_and_belongs_to_many between profile and user.
How to solve this problem? Am I wrong somewhere. Please guide me.
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-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: blacklist

2009-02-27 Thread madhavi.k




Is there any links for list out the badwords in rails application?

On Feb 27, 5:08 pm, vimal cool.vimalsm...@gmail.com wrote:
 I haven't used blacklist either
 I just traced the error in ur code
 ---
 c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
 `gem_original_require': no such file to load -- RedCloth
 (MissingSourceFile)
         from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/
 custom_require.rb:
         27:in
 
 I guess the blacklist gem needs RedCloth(a dependency) too

 Just try to restart the server and check for errors.i think there wont
 be any other additional code
 Try to get the follow through in the Blacklist documentation correct
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: simple select

2009-02-27 Thread Petan Cert

Thx for all your suggestions, but it always ended up with this error.

NoMethodError in GalleriesController#index
undefined method `photos' for #Class:0x54a56dc

  def index
  @title = gallery preview
  @user = User.find(params[:user_id])
  @gallery = @user.galleries
  @primary = @gallery.photos.primary.first
  end

I think, that my routes should be fine.

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

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



[Rails] Re: Q: find :include

2009-02-27 Thread rails.n...@gmail.com

 what exactly do you want to do???

I just didn't want to make a new query everytime i accessed a user of
a post

However, Fred is right 
http://www.akitaonrails.com/2008/5/26/rolling-with-rails-2-1-the-first-full-tutorial-part-2

So 2 queries is ok! :)

thanks guys

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



[Rails] Re: Problem with select_tag

2009-02-27 Thread vimal

I am a little busy
for better understanding
http://guides.rails.info/form_helpers.html
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] list out

2009-02-27 Thread madhavi.k

In my application i have a column like description of type text area.

I Installed Blacklist gem and Redcloth plugin(dependency) .

when I entered blacklist words in text area what should it do?(in my
application it does nothing)

Do I need to relate the plugin or gem to my application.


reply is must.

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



[Rails] Re: strict XHTML compliant ajax library

2009-02-27 Thread Phlip

Lin Wj wrote:

 problem : i have to develope a app using ajax features and it has to run
 in an environment(web tv related) which is very strict about XHTML
 compliance.
 
 and ajax codes generated by rails doesnt seem to be compliant.
 (they work on normal webpages , but not in the webtv env)
 
 other than writing my own ajax codes and including them as helpers.
 
 is there any other way ?

Install my assert_xpath, and activate its assert_javascript.

(This currently uses Javascript-PurePerl, and I hope to upgrade that to a Ruby 
solution shortly.)

Each page needs a test case like this:

   def test_foo_is_tidy
 get :foo
 assert_tidy
   end

If you put Strict XHTML into your DOCTYPE, then tidy should enforce that.

Next, to test an Ajax call, you would do this:

   xhr :get, :xhr_change_the_frob
   assert_js_replace_html :frob do
 assert_xpath :'form/input[ @name = baz and @value = 42 ]'
   end

assert_js_replace_html lexes the returned JavaScript, finds the 
Element.update() 
command, and parses the XHTML inside it. The do-end block sees that XHTML, so 
you can do further queries on it.

All these tests will fail if the XHTML has a single ill-formed tag.

At my day-job, we enforce strict Transitional XHTML, even though we only 
target wildly forgiving browsers, and even though our production code could get 
away with sloppy HTML. We do this because enforcing XHTML makes all our view 
tests much easier to write.

-- 
   Phlip


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



[Rails] Re: simple select

2009-02-27 Thread Eifion Bedford
It looks from your code as if you're returning a list of user galleries
rather than a single one, so the list you get won't have a photos method.
Does your code work if you change the third line in your method to

@gallery = @user.galleries.first

Eifion
http://asciicasts.com
Twitter: @eifion




On Fri, Feb 27, 2009 at 12:47 PM, Petan Cert 
rails-mailing-l...@andreas-s.net wrote:


 Thx for all your suggestions, but it always ended up with this error.

 NoMethodError in GalleriesController#index
 undefined method `photos' for #Class:0x54a56dc

  def index
  @title = gallery preview
  @user = User.find(params[:user_id])
  @gallery = @user.galleries
  @primary = @gallery.photos.primary.first
  end

 I think, that my routes should be fine.

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

 


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



[Rails] Re: replace_html and render action?

2009-02-27 Thread Sijo Kg

So from the view where you called this def you might have used 
link_to_remote or some thing like that..isn't it? So add
:update = contentBody to that

Now in action  just write

render :action = 'new'

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

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



[Rails] text library

2009-02-27 Thread Benjamín Cárdenas Salamandra

hola,

I need text library, but in text.rubyforge.org only appears the doc 
information. how i can download de library?, in rubyforge search don't 
find, and in google nor. anyone know?

thanks in advance,

Benjamín

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



[Rails] Re: replace_html and render action?

2009-02-27 Thread Heinz Strunk

Yep, I just figured out that :update was missing right after I posted 
that, 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-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: simple select

2009-02-27 Thread Petan Cert

Eifion Bedford wrote:
 It looks from your code as if you're returning a list of user galleries
 rather than a single one, so the list you get won't have a photos 
 method.
 Does your code work if you change the third line in your method to
 
 @gallery = @user.galleries.first
 

Yes, thats the error.
Now it is working but just for the first one.

Is there a way to loop all of the users galleries?
Thank you.

P.

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

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



[Rails] Maintaining session data across multiple domains

2009-02-27 Thread Adam

I'm working on an application that can be accessed from multiple
domains. I want to maintain session data across these domains, such
that if a user logs in at www.domain1.com, then moves to www.domain2.com,
they will still be logged in with the same account. Is this possible
in Rails? Could anyone point me towards a guide of how to achieve it?

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



[Rails] Re: simple select

2009-02-27 Thread MaD

well if you want all the primary photos just use my suggested
named_scope. then you can ask:
  @all_primary_photos = Photo.all.primary # or just Photo.primary
  @all_galleries = Gallery.all
no loop needed. but if you want to loop, you can do that with
  @all_galleries.each do |gallery|
# gallery.photos
  end

On 27 Feb., 15:05, Petan Cert rails-mailing-l...@andreas-s.net
wrote:
 Eifion Bedford wrote:
  It looks from your code as if you're returning a list of user galleries
  rather than a single one, so the list you get won't have a photos
  method.
  Does your code work if you change the third line in your method to

  @gallery = @user.galleries.first

 Yes, thats the error.
 Now it is working but just for the first one.

 Is there a way to loop all of the users galleries?
 Thank you.

 P.

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



[Rails] what / when calls create function in an ActionController ?

2009-02-27 Thread --- z...@m ---

Hi friends ,

i am newbie and was trying to learn rails by following a tutorial
which uses attachment_fu to upload videos .! every thing was working
till i edited something somewhere ! the problem is that nothing
happens when i click the submit button

the new.html.erb is as follows and it displays well too

h2Upload Advertisements 1/h2br /

% form_for(@advertisement, :html = { :multipart = true }) do |f| %
  %= f.error_messages %
  table
tr
  td%= f.label :title %: /tdtd%= f.text_field :title %/
td
/tr
tr
  td%= f.label :description %: /tdtd%=
f.text_area :description %/td
/tr
tr
  td%= f.label :advertisement %: /tdtd%=
f.file_field :uploaded_data %/td
/tr
trtd%= f.submit 'Submit' % - %= link_to 'Back',
advertisements_path %/td/tr
  /table

% end %

and the create function in the Controller is as follows

def create

@advertisement = Advertisement.new(params[:advertisement])

#...@advertisement.write_to_log

if @advertisement.save
   @advertisement.convert
   flash[:notice] = 'Advertisement has been uploaded'
   redirect_to :action = 'index'
else
   @advertisements = Advertisement.find(:all)
   render :action = 'new'
end
  end

even deleting the create function , it shows no error but returns to
index page when submit button clicked . it seems that this function is
not called properly

help appreciated
thanks in advance



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



[Rails] Re: what / when calls create function in an ActionController ?

2009-02-27 Thread Starr Horne

 even deleting the create function , it shows no error but returns to
 index page when submit button clicked . it seems that this function is
 not called properly

Have you set up your routes.rb file?

SH

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



[Rails] upload file to save

2009-02-27 Thread norricorp

I am new to rails and am stuck on the above.
I have used a mixture of code from the agile web dev with rails book
and what I have found with google.
I realise there are easier ways to do this with various plugins but I
would be interested to know why my code does not work.
The code runs and a file is created in the expected place but this
file is zero length so something is wrong.
Model code
class Photo  ActiveRecord::Base

  belongs_to :user

  validates_format_of :content_type,
  :with = /^image/,
  :message = --- you can only upload pictures

  def uploaded_picture=(picture_field)
self.photofile = base_part_of
(picture_field.original_filename)
self.content_type = picture_field.content_type.chomp
self.is_visible = 0
@data = picture_field.read
  end
etc etc

Controller code
  def create
  @photo = Photo.new(params[:photo])
  filename = @photo.photofile
  directory = public/images
# create the file path
  user= User.find(session[:userid])
  path = File.join(directory, user.user_id)
  if File.exist?(path) == false
   Dir.mkdir(path)
  end
  path = File.join(directory, user.user_id, filename)
# write the file
#   File.new(path, wb) { |f| f.write(params[:picture_field].read) }
 File.new(path, wb) { |f| f.write(@data) }

and the view
% form_for(:photo,
:url = {:action = 'create'},
:html = { :multipart = true }) do |f| %

  p
bCaption/bbr /
%= f.text_field :caption %
  /p
  Upload your picture: %= f.file_field(uploaded_picture) %br/
p
%= f.submit Upload Photo %
  /p
% end %

So there are obviously some basics here that I have not yet got.

Many thanks for looking

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



[Rails] Re: Problem with select_tag

2009-02-27 Thread thitima panyayai
thank you very much ,i can fix it  -__-

2009/2/27 Sijo Kg rails-mailing-l...@andreas-s.net


 change like

 %= form.select :organelle, ([,
 mitochondrion, nucleomorph, plastid, mitochondrion:
 kinetoplast,
 plastid: chloroplast, plastid: apicoplast, plastid:
 chromoplast,
 plastid: cyanelle, plastid: leucoplast, plastid:
 protoplastid ])
 %

 and it will submit to the create action of seqfeature controller.
 .There you can write the code as in def view

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

 


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



[Rails] Re: what / when calls create function in an ActionController ?

2009-02-27 Thread MaD

http://api.rubyonrails.com/classes/ActionView/Helpers/FormHelper.html

example taken form the above link:
  # Note: a @person variable will have been created in the controller.
  # For example: @person = Person.new
  % form_for :person, @person, :url = { :action = create } do |f|
%
%= f.text_field :first_name %
%= f.text_field :last_name %
%= submit_tag 'Create' %
  % end %

what you got is this:
  % form_for(@advertisement, :html = { :multipart = true }) do |f|
%
%= f.text_field :title %
%= f.text_area :description %
%# ... %
  %= f.submit 'Submit' %

now try changing your first line to:
  % form_for :advertisement, @advertisment, :url = { :action =
create }, :html = { :multipart = true } do |f| %

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



[Rails] Wierd to_a issue...

2009-02-27 Thread Ari

When I go to save a model, I get tons of these:

/usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
associations/association_proxy.rb:214: warning: default `to_a' will be
obsolete

It looks like the warning is coming from method_missing!

Even stranger: the model saves correctly in the development
environment, but under certain conditions it does not save in the
production environment -- even if operating with an identical
database.

Any ideas of what could be going on here?  I can't find anything about
this and am getting frustrated.  Any tips on how to trace where the
warnings are coming from would be helpful.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Getting unique entries from models?

2009-02-27 Thread Robert Walker

Mike Chai wrote:
 I'm using acts_as_taggable_on and I want to get a list of unique
 taggings. How can I do this? In a more general sense, say that I have
 a Product model with attributes name and price. I have these:
 
 id: 1
 Name: Juice
 Price: 5
 
 id: 2
 Name: Juice
 Price: 5
 
 So when I do a Product.find(:all) I'll get both, but I only want one.
 How can I do this so that no matter now many duplicates there are,
 I'll only get one PLUS all the other UNIQUE products?

I'm confused. How does this relate to acts_as_taggable_on?

What I see here is that you have a products table that allows the 
product name to be duplicated. This sounds like a bad idea to me. It 
seems more logical to either validate that the product name is unique 
with a unique index in the database to ensure the name is always unique. 
Or identify your products by something other than the name (like maybe 
SKU Number or Item Number). Something exposed to the user that they can 
use to find the right product.

Product.find(:all) is supposed to give you both. That's what it does. If 
you must insist on doing a distinct select then you'll have to drop down 
to a lower level like...

Product.find_by_sql(SELECT DISTINCT name, price from products)

But, again this seems like a really bad idea because you have no idea 
which one you're going to get and if you included the id in the distinct 
select then you would still get both anyway.

With all that said, I think you need to reevaluate your application's 
design.
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] SQL search

2009-02-27 Thread Ga Ga

How I write it in rails format? Articles.find( )

SELECT *, MATCH(title, body) AGAINST('$keyword') AS score FROM articles
WHERE MATCH(title, body) AGAINST('$keyword') ORDER BY score DESC
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: SQL search

2009-02-27 Thread Rob Biedenharn

On Feb 27, 2009, at 11:29 AM, Ga Ga wrote:
 How I write it in rails format? Articles.find( )

 SELECT *, MATCH(title, body) AGAINST('$keyword') AS score FROM  
 articles
 WHERE MATCH(title, body) AGAINST('$keyword') ORDER BY score DESC


Obviously, you'd have to try it yourself, but:

match_part = sanitize_sql(['MATCH(title, body) AGAINST(?)', keyword])
Article.find(:all, :select = *, #{match_part} AS score,
  :conditions = match_part, :order = 'score DESC')

I'm guessing that the $keyword is from Perl, but I've assumed that you  
have a local variable called keyword. Look closely at whether the  
conditions end up correct or if things get double-escaped in the final  
SQL.

-Rob

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



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



[Rails] Re: attachment_fu and nested model forms

2009-02-27 Thread Tim

 Maybe you just omitted this, but I think your CoverImage should declare
 belongs_to :product

Thanks for the idea Craig.  Thought we were on to something there for
a second but apparently not.

The update seems to work just not the create.  If I change the create
method to this: (yes I changed my image class and relationship names)

  def create
params[:product][:image] = ProductImage.new(params[:product]
[:image])
@product = Product.new(params[:product])

respond_to do |format|
  if @product.save
flash[:notice] = 'Product was successfully created.'
format.html { redirect_to(admin_products_path) }
format.xml  { render :xml = @product, :status
= :created, :location = @product }
  else
format.html { render :action = new }
format.xml  { render :xml = @product.errors, :status
= :unprocessable_entity }
  end
end
  end

it works fine and the update works as expected with a standard REST
action.

I also noticed that if I change the image relationship to has_many the
form fields aren't getting indexed so I end up with this:
input id=product_image_uploaded_data name=product[image]
[uploaded_data] size=30 type=file /

instead of this:
input id=product_image_0_uploaded_data name=product[image][0]
[uploaded_data] size=30 type=file /
etc...

I dunno seems like there must be something really fundamental that I'm
missing.

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



[Rails] Re: SQL search

2009-02-27 Thread Ga Ga

I get:

undefined method `sanitize_sql'

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

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



[Rails] Re: Maintaining session data across multiple domains

2009-02-27 Thread Frederick Cheung


On 27 Feb 2009, at 14:24, Adam wrote:


 I'm working on an application that can be accessed from multiple
 domains. I want to maintain session data across these domains, such
 that if a user logs in at www.domain1.com, then moves to www.domain2.com 
 ,
 they will still be logged in with the same account. Is this possible
 in Rails? Could anyone point me towards a guide of how to achieve it?


Well you will definitely need to move away from the cookie store.
I imagine you could do something like redirect users with no session  
to blah.domain.com - this creates/looks up their session id. Then it  
redirects them back to the original domain along with a token telling  
that app what the session id of the user should be (so that this app  
can set the cookie saying what the session id is)

Fred


 Many thanks,
 Adam
 


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



[Rails] Re: Getting unique entries from models?

2009-02-27 Thread Mike C

Thanks for the help. That was just an example, not a good one, but I
just needed to explain the problem I'm having. It had nothing to do
with acts_as_taggable_on, but I might as well just directly tell my
problem.

I want to display all the tags that a tagger has used. However, using
@user.owned_taggings returns ALL the taggings, including duplicates.
What I mean by duplicates, is that the taggable_type and the tag_id
are the same. That means if someone used one tag on many different
Products, it would be a list of that one word.

On Feb 27, 8:25 am, Robert Walker rails-mailing-l...@andreas-s.net
wrote:
 Mike Chai wrote:
  I'm using acts_as_taggable_on and I want to get a list of unique
  taggings. How can I do this? In a more general sense, say that I have
  a Product model with attributes name and price. I have these:

  id: 1
  Name: Juice
  Price: 5

  id: 2
  Name: Juice
  Price: 5

  So when I do a Product.find(:all) I'll get both, but I only want one.
  How can I do this so that no matter now many duplicates there are,
  I'll only get one PLUS all the other UNIQUE products?

 I'm confused. How does this relate to acts_as_taggable_on?

 What I see here is that you have a products table that allows the
 product name to be duplicated. This sounds like a bad idea to me. It
 seems more logical to either validate that the product name is unique
 with a unique index in the database to ensure the name is always unique.
 Or identify your products by something other than the name (like maybe
 SKU Number or Item Number). Something exposed to the user that they can
 use to find the right product.

 Product.find(:all) is supposed to give you both. That's what it does. If
 you must insist on doing a distinct select then you'll have to drop down
 to a lower level like...

 Product.find_by_sql(SELECT DISTINCT name, price from products)

 But, again this seems like a really bad idea because you have no idea
 which one you're going to get and if you included the id in the distinct
 select then you would still get both anyway.

 With all that said, I think you need to reevaluate your application's
 design.
 --
 Posted viahttp://www.ruby-forum.com/.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: list out

2009-02-27 Thread Ar Chron

 
 Do I need to relate the plugin or gem to my application.
 
Of course.

From the README.textile:

It will also work out of the box as a Ruby on Rails plugin. Just drop it 
in vendor/plugins and it’ll work.

 when I entered blacklist words in text area what should it do?(in my
 application it does nothing)

Are you asking it to do anything?  Again, from the README file:

BlackList.block?(Stupid ass simple.)

The example is giving Blacklist a string, you'll probably want to pass 
it the contents of the textarea.
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Table relation problems

2009-02-27 Thread Israel Guerra
Hi.

I need to know if it's possible to do something like this:
http://pastie.org/402205

The table game_guesses has 2 keys for team: home_key and guest_key. The
problem is that a normal relation would be team has_many/has_one
game_guessbut that is not the case.

I just want to see the team information using guess.homeTeam.name or
guess.guestTeam.name (or other information of the Team object)

Is there a way to solve it? I tried to change the model, but eventually it
would lead to a situation like this one.

Thanks,
--
Israel Guerra
Joan Rivers  - The first time I see a jogger smiling, I'll consider it.

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



[Rails] Authorization system recommendations

2009-02-27 Thread Evan

Good morning.

Our application has grown to the point where a more robust
authorization system is needed. What Rails plugins or Ruby gems do you
recommend?

Our needs include:

- defining multiple user roles which can use parts of the application
in different ways
- easy maintenance (preferably no generators or systems requiring
manual code updating after initial install)

We are already using authlogic for authentication.

Thanks.

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



[Rails] Re: SQL search

2009-02-27 Thread Ga Ga

Ga Ga wrote:
 I get:
 
 undefined method `sanitize_sql'

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

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



[Rails] Re: beginners question

2009-02-27 Thread ruud

hi Gavin,

I inserted two observe_field calls, essentially replacing the onclick
values on the radio button tags. But it turns out that only the first
time a radio button is clicked, the :function of the observer is
called. So if I switch back, nothing happens. It does if I reload the
page.
Do I miss something in the documentation?

regards, Ruud

[ options hash delete from input tags]
[inserted]
%= observe_field( :date_none, :function = 'date_clicked(true)')
%
%= observe_field( :date_with, :function = 'date_clicked(false)')
%

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



[Rails] Polymorphic association..explain the extra query ?

2009-02-27 Thread Arpit Jain
Can anyone explain to me the sql query done in the last step :

http://pastie.org/402200

-- 
Arpit Jain

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



[Rails] Re: Regarding IDE

2009-02-27 Thread ghettoiam

I'd second/third NetBeans.  I use NetBeans on all platforms mac/ubunut/
winXP and I think it's great.  Particularly because of its auto-
completion, built-in documentation of ruby methods and easy debugger.
It really shortened the learning curve when I originally jumped into
rails.

On Feb 26, 1:51 pm, Robert Walker rails-mailing-l...@andreas-s.net
wrote:
 Cyrus Dev wrote:

  Hello Every one,

  I am using SciTE Editor which is good for ruby and rails, but I want
  editor
  with file browser in that , is any plugin available for it ?

  thanks

 Are you looking for a full-on IDE or just a better text editor?

 I use, an highly recommend, TextMate on the Mac. The is something
 similar to it on Windows called the E Text Editor.

 If you are looking for a full-fledged IDE for Ruby take a loot at
 Netbeans 6.5. It seems to be about the best Ruby support I know of in an
 IDE.

 People may think it's strange that I really prefer a good text editor
 like TextMate over an IDE. Especially, since I live in an IDE all day
 for my Java day job. But, Java just isn't practical without an IDE
 these days.

 Here are some things I dislike about IDEs:

 1. Most are written in Java. The exception being Xcode, which is the
 only IDE I actually enjoy using.
 2. IDEs tend to lock you into a single vendor. In our case that's Oracle
 with their JDeveloper IDE.
 3. I HATE Java programs.
 4. I REALLY HATE Java programs.
 5. IDEs have a tendency to make bad assumptions. Oh!. Here's what I
 think you're trying to do, I'll go ahead and make that edit for you. I
 swear, I spend half my time removing crap that the IDE thinks I want.
 6. I'm a programmer. I don't need help with programming! What I need is
 help editing text. TextMate is perfect for this because the developers
 spend their time thinking about editing text/code. The built-in text
 editors of most IDE are horrible at editing text.
 7. JDeveloper startup time ~30 seconds. TextMate Startup time  1
 second.
 8. mate .

 This is all a matter of taste, but is probably the primary thing that
 drew me to Ruby on Rails in the first place. A development framework
 that's logical enough to require no IDE is worth it's weight in gold.
 --
 Posted viahttp://www.ruby-forum.com/.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Stupid Question - Need to get a field from table...

2009-02-27 Thread Tony Tony

Hi all,

I'm ashamed to ask this but I can't figure it out. Lately my brain gets
more burned out by the minute. Basically I'm trying to have a shirt have
up to 2 colors. I currently have this working. When I edit a shirt, I
can select the primary and secondary color of a shirt. But when I want
to see the colors in the show page I can't manage to see the name only
the id.


For example:

  bPrimary Color:/b
  %=h @shirt.color_id %br /

  bSecondary Color:/b
  %=h @shirt.color2_id %br /

Only displays the id (obviously) but what I want to see is the NAME OF
THE COLOR. I just can't think of a way to do this for some reason. Maybe
there is a better way to do this and you guys can shed a light?



Below is the database structure and model relationship code...

APPROVED_COLORS (table name/structure in db)
---
:id (int)
:name (string)

SHIRTS (table name/structure in db)
---
:color_id (int)
:color2_id (int)


APPROVED_COLOR.RB

belongs_to :shirt


SHIRT.RB
--
has_many :approved_colors


Any help on this is greatly appreciated.

Thanks,
Tony
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: beginners question

2009-02-27 Thread Gavin

Hi Ruud

Hmm  - I've never used observe_field to call a js function, usually
just for rails-ajax calls.

If I were calling a js function like so,  I'd normally just
add :onclick = 'date_clicked(true)' to the radio buttons.

There should be a way to call the js function using observe_field
though so let's try and find it?

Why not try simplifying the function call first, with something
like :function = alert('this works') just to check if this is where
the problem is?

what do you have in the date_clicked() function now?


On Feb 27, 5:51 pm, ruud r.grosm...@gmail.com wrote:
 hi Gavin,

 I inserted two observe_field calls, essentially replacing the onclick
 values on the radio button tags. But it turns out that only the first
 time a radio button is clicked, the :function of the observer is
 called. So if I switch back, nothing happens. It does if I reload the
 page.
 Do I miss something in the documentation?

 regards, Ruud

 [ options hash delete from input tags]
 [inserted]
     %= observe_field( :date_none, :function = 'date_clicked(true)')
 %
     %= observe_field( :date_with, :function = 'date_clicked(false)')
 %
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] rails array.each returning array?

2009-02-27 Thread Sergio Ruiz

i am having a problem with a current piece of code, and it seems like
the result for each on an array might be the culprit.

according to everything i have seen before, this should work:

   a = [ a, b, c ]
   a.each {|x| print x,  --  }

should produce:

  a -- b -- c --


but i am getting:

 a = [ a, b, c ]
= [a, b, c]
 a.each {|x| print x,  --  }
a -- b -- c -- = [a, b, c]

does anyone know where the = [a, b, c] is coming from?

specifically, i am trying to run:

 def self.show_pending_users
self.find(:all, :conditions = pending_role is not null).each {
|x| #{x.login}  }
  end

where i expect to get a an array of x.login back.. but i am getting back
an array of all the objects ...

any ideas?

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-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: rails array.each returning array?

2009-02-27 Thread Starr Horne

 does anyone know where the = [a, b, c] is coming from?

It's only doing that in the console, because the return value of each is the
array you passed it. If you run this code outside of irb, you won't see it.

SH

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



[Rails] Re: rails array.each returning array?

2009-02-27 Thread Maurício Linhares

What you want is map, not each (the ruby-doc is always your friend):

def self.show_pending_users
   self.find(:all, :conditions = pending_role is not null).map {|x|
#{x.login}  }
 end

-
Maurício Linhares
http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en)



On Fri, Feb 27, 2009 at 3:30 PM, Sergio Ruiz
rails-mailing-l...@andreas-s.net wrote:

 i am having a problem with a current piece of code, and it seems like
 the result for each on an array might be the culprit.

 according to everything i have seen before, this should work:

   a = [ a, b, c ]
   a.each {|x| print x,  --  }

 should produce:

  a -- b -- c --


 but i am getting:

 a = [ a, b, c ]
 = [a, b, c]
 a.each {|x| print x,  --  }
 a -- b -- c -- = [a, b, c]

 does anyone know where the = [a, b, c] is coming from?

 specifically, i am trying to run:

  def self.show_pending_users
    self.find(:all, :conditions = pending_role is not null).each {
 |x| #{x.login}  }
  end

 where i expect to get a an array of x.login back.. but i am getting back
 an array of all the objects ...

 any ideas?

 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-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: rails array.each returning array?

2009-02-27 Thread Sergio Ruiz

Maurício Linhares wrote:
 What you want is map, not each (the ruby-doc is always your friend):
 

ah!

this ended up working perfectly..

thanks so much 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-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] streamlined - inset_table or membership in edit_view

2009-02-27 Thread Sergio Ruiz

for some reason, i cannot get this to work..

this is the very last piece of this entire project that is needed for
completion, and it's totally stumping me..

what i have is a relationship in edit view that is showing up as
a :select. i would like it to show up as an inset_table (i think.. i
would like it to show up just like it does in list view, when edit is
selected..).. but i just can't seem to get anything but :select to
show up..

i see there is another post to this list, but it looks like it was
never resolved..

here is what my edit view looks like:

module CareerAdditions

end
Career.class_eval { include CareerAdditions }

Streamlined.ui_for(Career) do
  user_columns :title,
  :description,
  :schools, {:edit_view = [:filter_select]},
  :pathway,
  :youtube_link,
  :salary,
  :documents
end

the relationship between schools and careers is:

has_and_belongs_to_many

i have also tried changing user_columns to edit_columns with no
luck..

if anyone has any ideas, i would throw you massive karma points..

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-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: SQL search

2009-02-27 Thread Rob Biedenharn

On Feb 27, 2009, at 11:42 AM, Rob Biedenharn wrote:
 On Feb 27, 2009, at 11:29 AM, Ga Ga wrote:
 How I write it in rails format? Articles.find( )

 SELECT *, MATCH(title, body) AGAINST('$keyword') AS score FROM
 articles
 WHERE MATCH(title, body) AGAINST('$keyword') ORDER BY score DESC


 Obviously, you'd have to try it yourself, but:

 match_part =
self.class.
 sanitize_sql(['MATCH(title, body) AGAINST(?)', keyword])
 Article.find(:all, :select = *, #{match_part} AS score,
  :conditions = match_part, :order = 'score DESC')

 I'm guessing that the $keyword is from Perl, but I've assumed that you
 have a local variable called keyword. Look closely at whether the
 conditions end up correct or if things get double-escaped in the final
 SQL.

 -Rob

 Rob Biedenharnhttp://agileconsultingllc.com
 r...@agileconsultingllc.com


Sorry, if you look at the docs, sanitize_sql is a protected class  
method of ActiveRecord::Base

-Rob

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

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



[Rails] Re: Stupid Question - Need to get a field from table...

2009-02-27 Thread Craig Demyanovich
On Fri, Feb 27, 2009 at 1:20 PM, Tony Tony rails-mailing-l...@andreas-s.net
 wrote:


 Hi all,

 I'm ashamed to ask this but I can't figure it out. Lately my brain gets
 more burned out by the minute. Basically I'm trying to have a shirt have
 up to 2 colors. I currently have this working. When I edit a shirt, I
 can select the primary and secondary color of a shirt. But when I want
 to see the colors in the show page I can't manage to see the name only
 the id.


 For example:

  bPrimary Color:/b
  %=h @shirt.color_id %br /

  bSecondary Color:/b
  %=h @shirt.color2_id %br /


I'd make the following changes so that I could use more meaningful names for
the colors:

Models
==

class Shirt  ActiveRecord::Base
  belongs_to :primary_color, :class_name = ApprovedColor, :foreign_key =
color_id
  belongs_to :secondary_color, :class_name = ApprovedColor, :foreign_key
= color2_id
end

class ApprovedColor  ActiveRecord::Base
  has_many :shirts
end

Even though I've used Rails for quite awhile now, I still have to stop and
think sometimes about where the belongs_to and the has_many go. The
belongs_to goes where the foreign key exists, on Shirt in this case.

View


bPrimary Color:/b
%=h @shirt.primary_color.name %br /

bSecondary Color:/b
%=h @shirt.secondary_color.name if @shirt.secondary_color %br /

Regards,
Craig

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



[Rails] Re: Stupid Question - Need to get a field from table...

2009-02-27 Thread Tony Tony

Ideally something like this would be great:

%=h @shirt.approved_colors.color_id.name %

Any ideas? I don't know why my brain is shot today. Hate it.



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

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



[Rails] Re: Stupid Question - Need to get a field from table...

2009-02-27 Thread Rob Biedenharn

On Feb 27, 2009, at 1:20 PM, Tony Tony wrote:
 Hi all,

 I'm ashamed to ask this but I can't figure it out. Lately my brain  
 gets
 more burned out by the minute. Basically I'm trying to have a shirt  
 have
 up to 2 colors. I currently have this working. When I edit a shirt, I
 can select the primary and secondary color of a shirt. But when I want
 to see the colors in the show page I can't manage to see the name only
 the id.


 For example:

  bPrimary Color:/b
  %=h @shirt.color_id %br /
%=h @shirt.primary_color_name %



  bSecondary Color:/b
  %=h @shirt.color2_id %br /
%=h @shirt.secondary_color_name %



 Only displays the id (obviously) but what I want to see is the NAME OF
 THE COLOR. I just can't think of a way to do this for some reason.  
 Maybe
 there is a better way to do this and you guys can shed a light?



 Below is the database structure and model relationship code...

 APPROVED_COLORS (table name/structure in db)
 ---
 :id (int)
 :name (string)

 SHIRTS (table name/structure in db)
 ---
 :color_id (int)
 :color2_id (int)



 APPROVED_COLOR.RB
 
 belongs_to :shirt


 SHIRT.RB
 --
 has_many :approved_colors
has_one :primary_color, :class_name = 'ApprovedColor', :foreign_key  
= :color_id
has_one :secondary_color, :class_name = 'ApprovedColor', :foreign_key  
= :color2_id


 Any help on this is greatly appreciated.

 Thanks,
 Tony
 -- 


class Shirt
   def primary_color_name
 self.primary_color ? self.primary_color.name : '(none)'
   end
   def secondary_color_name
 self.secondary_color ? self.secondary_color.name : '(none)'
   end
end

If this doesn't quite work as-is, please take it as a strong hint and  
an exercise in using the documentation of has_one

-Rob

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

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



[Rails] Re: Automatically get a list of controller names

2009-02-27 Thread jasoo24

I would recommend that you hard-code that list and also include
controller names you may use in the future and reserved or restricted
words.

On Feb 26, 5:49 pm, Ramon Tayag ramon.ta...@gmail.com wrote:
 Okay, just a follow up question: is there an automatic way to make an
 array of all controller names?  So that I could use this in the user
 model to validate the user doesn't type in any of the controller
 names.

 (This is a continued conversation of one that asked about making
 routes this way:

 domain.com/username

 but still retaining the functionality to send the user to a controller
 if they typed:

 domain.com/controllername

 Ramon Tayag

 On Thu, Feb 26, 2009 at 5:34 PM, Chris Kottom chris.kot...@gmail.com wrote:
  Not sure I understand the behavior you're after completely, but should be
  able to do this by specifying a named route in your routes file before the
  default ones.

  Ex:
    map.user_profile   ':username', :controller = 'users', :action = 'show'
    map.connect    ':controller/:action/:id'
    ...

  This will have the effect, however, of matching any incoming request with
  only one string.  So you won't be able to have another route like:

    map.user_profile    ':username', :controller = 'users', :action = 'show'
    map.group_profile   ':groupname', :controller = 'groups', :action =
  'show'

  All requests here meant for either of these would be sent to the
  UsersController#show because it appears first in the routes file.

  Hope this answers your question.

  On Thu, Feb 26, 2009 at 4:08 AM, Ramon Tayag ramon.ta...@gmail.com wrote:

  Hey everyone!

  Is there a way of saying something like this in the routes file (note
  that map.connect :controller/:action/:id is my last pattern):
  If the controller you specified doesn't exist, then go to the next
  pattern

  I want this because if users type in domain.com/noncontrollername, I'd
  like the app to render or forward the user to
  domain.com/profiles/noncontrollername.  So, for example, if my
  username is ramon, and I type domain.com/ramon, I will see my profile.

  If this is not possible, what's a good way of doing this? :)

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



[Rails] random DBI::DatabaseError while querying SqlServer

2009-02-27 Thread Seyit Caglar Abbasoglu
*First some background:*

Application is running on a windows XP
I'm currently using Ruby version 1.8.6-26 with easy installer (I couldn't
manage to manually install 1.8.7)
Rails version is 2.2.2
activerecord version 2.2.2, 1.15.6
activerecord-sqlserver-adapter is version 1.0.0.9250
ADO.rb version is 0.1.0 (couldn't find anything newer, is it abandoned or
something?)
SqlServer 2000 (I tried with sql server 2005 same problem continues)

I don't know it's related but as session store I'm using active_record_store


*Problem*:
Database queries are generally working fine, but sometimes (lets say once in
30-40 queries) I get a strange error at sqlserver_adapter.rb, the error
message and stack trace is as follows.

DBI::DatabaseError: Value
OLE error code:8000 in Microsoft OLE DB Provider for SQL Server
  Iİşlem::Kaydet veya Iİşlem::Durdur çağrıldı ve nesne meşgul durumda.
HRESULT error code:0x80020009
  ?zel durum olu?tu.: SELECT * FROM [product] WHERE
([product].[isActive] = 1 AND [product].[useInMobileOrder] = 1)

C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract_adapter.rb:188:in
`log'
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-sqlserver-adapter-1.0.0.9250/lib/active_record/connection_adapters/sqlserver_adapter.rb:337:in
`execute'
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-sqlserver-adapter-1.0.0.9250/lib/active_record/connection_adapters/sqlserver_adapter.rb:538:in
`select'
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/database_statements.rb:7:in
`select_all_without_query_cache'
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/query_cache.rb:60:in
`select_all'
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/query_cache.rb:81:in
`cache_sql'
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/query_cache.rb:60:in
`select_all'
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/base.rb:635:in
`find_by_sql'
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/base.rb:1490:in
`find_every'
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/base.rb:589:in
`find'
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1253:in
`send'
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1253:in
`perform_action_without_filters'
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:617:in
`call_filters'
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:638:in
`run_before_filters'
C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:178:in
`send'
C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:178:in
`evaluate_method'
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:186:in
`call'
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:635:in
`run_before_filters'
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:615:in
`call_filters'
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:610:in
`perform_action_without_benchmark'
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:68:in
`perform_action_without_rescue'
C:/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure'
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:68:in
`perform_action_without_rescue'
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/rescue.rb:136:in
`perform_action_without_caching'
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/caching/sql_cache.rb:13:in
`perform_action'
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in
`cache'
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/query_cache.rb:8:in
`cache'
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/caching/sql_cache.rb:12:in
`perform_action'
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:524:in
`send'
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:524:in
`process_without_filters'
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:606:in
`process_without_session_management_support'
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/session_management.rb:134:in
`process'
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:392:in
`process'
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:183:in
`handle_request'
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:110:in
`dispatch_unlocked'

[Rails] Re: Stupid Question - Need to get a field from table...

2009-02-27 Thread Tony Tony

Thanks for the replies!

Craigs solution worked like a charm.



First time I use foreign_key.  I have a feeling that while this worked, 
the way it works (specifically having to specify foreign_key) is 
incorrect or rather defaults rails conventions. Is this the case? If so 
what can or should I do to make this work from now on?



Thanks again,
Tony
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: como consultar en oracle

2009-02-27 Thread pepe

Hola otra vez.

A mí me funcionó perfectamente el gem, pero he estado jugando con el
código y parece ser que lo he estropeado. Ahora estoy haciendo otras
cosas, pero en cuanto tenga un momento (posiblemente esta noche) y lo
resuelva te pongo aquí el ejemplo del código que he utilizado para ver
si siguiéndolo te funciona el tuyo.

Pepe

On Feb 26, 4:37 pm, Oraldo alarcon rails-mailing-l...@andreas-s.net
wrote:
  hola hermano un saludo fuerte

   men me puse a hacer lo que me dijistes pero tampoco funciona medio he
 resuelto el problema de esta manera
 sql = autosys_db.prepare(SELECT mtin_descri,mtin_mtin FROM re_tmtinv
 WHERE rownum =5) con este codigo solo puedo ver los primeros 5 pero no
 me deja ver los que siguen estuve investigando un poco mas me encontre
 otros metodos pero no se como adaptarlo 1.-SELECT * FROM (SELECT /*+
 FIRST_ROWS(n) */ *, ROWNUM rnum FROM (re_tmtinv) WHERE ROWNUM =
 limite-supWHERE rnum = limite-inf;
 2.-

 SELECT *FROM (SELECT /*+ FIRST_ROWS(10) */ @limit.*, ROWNUM rnumFROM
 (SELECT id, mtin_mtin FROM re_tmtinv ORDER BY id, rowid) WHERE ROWNUM =
 20) WHERE rnum = 10;
  este no me deja hacer nada por el tipo de version

 3.-SELECT  TOP 10 t.* FROM re_tmtinv as t where t.id = not in( SELECT
 TOP 0 id from re_tmtinv order by id desc )order by t.id desc
  por casualidad has coseguido algo mejor
  espero su pronta respuesta gracias

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



[Rails] Re: como consultar en oracle

2009-02-27 Thread pepe

Creo que los SELECT que pones ahí van por buen camino, pero no soy
experto en SQL y no sabría cómo hacer lo que necesitas. Creo que
deberías intentar instalar el adaptador de Oracle. Te aseguro que una
vez que lo tengas instalado no vas a volver a querer utilizar SQL puro
y duro excepto a lo mejor para acciones muy complejas y tus problemas
se van a solucionar de golpe.

Pepe

On Feb 26, 4:37 pm, Oraldo alarcon rails-mailing-l...@andreas-s.net
wrote:
  hola hermano un saludo fuerte

   men me puse a hacer lo que me dijistes pero tampoco funciona medio he
 resuelto el problema de esta manera
 sql = autosys_db.prepare(SELECT mtin_descri,mtin_mtin FROM re_tmtinv
 WHERE rownum =5) con este codigo solo puedo ver los primeros 5 pero no
 me deja ver los que siguen estuve investigando un poco mas me encontre
 otros metodos pero no se como adaptarlo 1.-SELECT * FROM (SELECT /*+
 FIRST_ROWS(n) */ *, ROWNUM rnum FROM (re_tmtinv) WHERE ROWNUM =
 limite-supWHERE rnum = limite-inf;
 2.-

 SELECT *FROM (SELECT /*+ FIRST_ROWS(10) */ @limit.*, ROWNUM rnumFROM
 (SELECT id, mtin_mtin FROM re_tmtinv ORDER BY id, rowid) WHERE ROWNUM =
 20) WHERE rnum = 10;
  este no me deja hacer nada por el tipo de version

 3.-SELECT  TOP 10 t.* FROM re_tmtinv as t where t.id = not in( SELECT
 TOP 0 id from re_tmtinv order by id desc )order by t.id desc
  por casualidad has coseguido algo mejor
  espero su pronta respuesta gracias

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



[Rails] Re: Stupid Question - Need to get a field from table...

2009-02-27 Thread Craig Demyanovich
On Fri, Feb 27, 2009 at 2:33 PM, Tony Tony rails-mailing-l...@andreas-s.net
 wrote:


 Thanks for the replies!

 Craigs solution worked like a charm.


Cool.


 First time I use foreign_key.  I have a feeling that while this worked,
 the way it works (specifically having to specify foreign_key) is
 incorrect or rather defaults rails conventions. Is this the case? If so
 what can or should I do to make this work from now on?


Using the :foreign_key option isn't incorrect. It's there if you need to
circumvent the Rails defaults for any reason. If you didn't want to use the
:foreign_key option, you could use a migration to rename the color_id and
color2_id columns in your shirts table to primary_color_id and
secondary_color_id, respectively. Then, you could just declare your
associations like this:

class Shirt  ActiveRecord::Base
  belongs_to :primary_color, :class_name = ApprovedColor
  belongs_to :secondary_color, :class_name = ApprovedColor
end

Regards,
Craig

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



[Rails] Regular Expression question

2009-02-27 Thread northband

Hi -

I would like to use gsub() to strip decimals with trailing zeros from
a string.  My string looks like this:
--
19.0  / 482.600 mm
--

I would like to end up with this:
--
19  / 482.6 mm
--

Anyone have a regular expression that can do this?

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



[Rails] Re: Modify beginning_of_week?

2009-02-27 Thread pepe

I see 2 ways you could do this

1. Re-open the class that offers the functionality and add your code
to modify the behavior. I would not recommend that. I like leaving
code that I didn't write as it is.
2. Create something very simple that receives the parameter you need
and acts accordingly to use the existing beginning_of_week behavior
and get what you want.

On Feb 26, 7:58 pm, Guillaume Loader rails-mailing-l...@andreas-
s.net wrote:
 Hello everyone!

 Is it possible to modify this function: beginning_of_week?

 What I want is something like this :
 beginning_of_week(0) returns Sunday
 beginning_of_week(1) returns Monday

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



[Rails] Re: SQL search

2009-02-27 Thread Ga Ga

Rob Biedenharn wrote:
 On Feb 27, 2009, at 11:42 AM, Rob Biedenharn wrote:
 match_part =
 self.class.

 Rob Biedenharnhttp://agileconsultingllc.com
 r...@agileconsultingllc.com
 
 
 Sorry, if you look at the docs, sanitize_sql is a protected class
 method of ActiveRecord::Base
 

Is there some alternative way to it, and not to use protected classes?
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: How do I access a variable defined in application.rb from within application.rhtml?

2009-02-27 Thread ericindc

Thanks, this sounds like what I need.

On Feb 22, 7:24 pm, Jeff Lewis jeff.bu...@gmail.com wrote:
 To initialize some db-read var (tidbit in your example) that would
 survive and be callable for each subsequent app request, you'll want
 to do so via lazy-initialization using a before_filter (mentioned by
 bill) in application.rb.

 How you store such lazy-init vars between requests depends on the
 scope/use of such vars by users/requests of the app:

 If the var that you're setting is specific to some user alone, and
 should not be shared by all users' requests, then you could store that
 var in the user's session:

 # in ./app/controller/application.rb
   ...
   before_filter :do_lazy_init

   ...
   private

   def do_lazy_init
     session[:tidbit] = Tidbit.random if not session[:tidbit]
     @tidbit = session[:tidbit]
   end

 which all of your app controller meths and view templates could then
 use via @tidbit.

 Note that such session vars can survive app restarts.  So if you
 really want the var to be set at app start/restart, and/or you change
 the structure/content of tidbit in the db, you'll want to clear such
 session data first before re-starting your app.

 If var that you're setting really is global in scope, intended to be
 shared by all users' requests and is read-only, then you could store
 it in a global var:

 # in ./app/controller/application.rb
   ...
   before_filter :do_lazy_init

   ...
   private

   def do_lazy_init
     $global_tidbit = Tidbit.random if not $global_tidbit
     @tidbit = $global_tidbit
   end

 Beware of issues surrounding use of global vars tho, and definitely
 don't use mutable global vars, due to potential data incongruity
 issues, especially when running production environment (assuming more
 than one process-/thread-instance of your app in prod env).

 If you're interested in Matz's opinion on use of global vars, per
 quote in Ruby Pocket Ref (http://books.google.com/books?
 id=KZU_HUYJ5yMCpg=PA13dq=ruby+matz+global+variables): They're ugly,
 so don't use them.

 Jeff

 On Feb 21, 4:29 pm,ericindcericmilf...@gmail.com wrote:

  I don't generally follow the whatever works... approach because
  there is usually a best practice.  That said, I want to avoid the
  global variable because having $tidbit = Tidbit.random declared in my
  application.rb broke my migrations.  Running migrations from version 0
  when the Tidbits database doesn't exist caused the db:migrate to fail
  because the line of code was still being executed and the Model was
  attempting to access a table that didn't exist.

  I'll keep reading, but I'm sure there is a logical way of
  accomplishing this that I'm just not yet seeing.  Thanks.

  On Feb 21, 4:41 pm, Eric ericgh...@gmail.com wrote:

   So why not use that, then? Whatever works...

   Also, you might brush up on MVC and beginner's Ruby as far as setting
   variables in models 
   go:http://wiki.rubyonrails.org/rails/pages/UnderstandingRailsMVC

   On Feb 21, 12:45 pm,ericindcericmilf...@gmail.com wrote:

Title pretty much explains it.  I'd like to set a variable the stores
a single Model object inside of application.rb since it will be used
on every single page.  I've tried both class and instance variables,
but to no avail.  The only thing that worked so far was using a global
($) variable.


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



[Rails] Re: Applying default conditions to a model's find, find_by_*

2009-02-27 Thread ericindc

Not at this point, so I'd prefer to come up with a solution using
2.2.2.

On Feb 27, 12:46 am, Craig Demyanovich cdemyanov...@gmail.com wrote:
 If you can move to Rails 2.3, which is currently in release candidate
 testing, you could use default 
 scoping:http://ryandaigle.com/articles/2008/11/18/what-s-new-in-edge-rails-de...

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



[Rails] Re: Remove trailing zeros

2009-02-27 Thread pepe

Maybe you can convert them to integers?

my_float = 2.0
my_float = my_float.to_i if my_float == my_float.to_i

Pepe

On Feb 27, 1:20 am, northband northb...@gmail.com wrote:
 Hi -

 I am working with floats and am wondering how I can trim the decimal
 and trailing zeros on my whole numbers.  For instance, whole numbers
 are being displayed as 1.0, 2.0, 3.0, etc...  I would like to remove
 the decimal and any trailing zeros with out effecting other non-whole
 number floats (ex. 1.375).

 Any ideas?  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-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Applying default conditions to a model's find, find_by_*

2009-02-27 Thread Maurício Linhares

At your model, override the find method:

class SomeModel  ActiveRecord::Base

  class  self

def find(*args)
  with_scope( :conditions = {:property = 'value'} ) do
super(*args)
  end
end

  end

end


-
Maurício Linhares
http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en)



On Fri, Feb 27, 2009 at 5:11 PM, ericindc ericmilf...@gmail.com wrote:

 Not at this point, so I'd prefer to come up with a solution using
 2.2.2.

 On Feb 27, 12:46 am, Craig Demyanovich cdemyanov...@gmail.com wrote:
 If you can move to Rails 2.3, which is currently in release candidate
 testing, you could use default 
 scoping:http://ryandaigle.com/articles/2008/11/18/what-s-new-in-edge-rails-de...

 Regards,
 Craig
 


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



[Rails] Re: Stupid Question - Need to get a field from table...

2009-02-27 Thread Tony Tony

Craig Demyanovich wrote:
 Using the :foreign_key option isn't incorrect. It's there if you need to
 circumvent the Rails defaults for any reason. If you didn't want to use 
 the
 :foreign_key option, you could use a migration to rename the color_id 
 and
 color2_id columns in your shirts table to primary_color_id and
 secondary_color_id, respectively. Then, you could just declare your
 associations like this:
 
 class Shirt  ActiveRecord::Base
   belongs_to :primary_color, :class_name = ApprovedColor
   belongs_to :secondary_color, :class_name = ApprovedColor
 end
 
 Regards,
 Craig

Good lord you're good. :-)

I really need to stop hacking and start learning more (even though I 
have learned a lot). Many thanks again for your help. I ended up going 
the foreign_key-less way.


-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-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] warning users that the site is coming down for maintenance

2009-02-27 Thread yber...@msn.com

Hi. I have a site that is currently running in alpha mode. I have
warned my users that it will be bouncing up and down as I deploy
updates. That said, i'd like to broadcast a real time warning to them
when I am about to do so. Something along the lines of:

The site will be brought down for maintenance in five minutes. Save
your work and logout to avoid losing data.

Any clever suggestions on how to do this?

A colleague suggested to me that I have a javascript on each page that
polls the server for a change in status and pos up an alert. I'm
looking for other creative suggestions...

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



[Rails] Re: Remove trailing zeros

2009-02-27 Thread northband_101

Thanks - this seems easy enough.



On Feb 27, 3:12 pm, pepe p...@betterrpg.com wrote:
 Maybe you can convert them to integers?

 my_float = 2.0
 my_float = my_float.to_i if my_float == my_float.to_i

 Pepe

 On Feb 27, 1:20 am, northband northb...@gmail.com wrote:

  Hi -

  I am working with floats and am wondering how I can trim the decimal
  and trailing zeros on my whole numbers.  For instance, whole numbers
  are being displayed as 1.0, 2.0, 3.0, etc...  I would like to remove
  the decimal and any trailing zeros with out effecting other non-whole
  number floats (ex. 1.375).

  Any ideas?  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-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Association through 2 intermediate Models

2009-02-27 Thread Tonypm

perhaps the responses could be a bit more helpful here?

sol,

I have done it through 2 level associations using through

eg.

Sites

has_many :feed_entries, :through=:feeds

I have tried with 3 levels, but never got it to work, ie, how do you
chain the throughs.  I have tried to make sure that the through is in
place at each level, but to no avail.

Perhaps someone may be able to enlighten us.

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



[Rails] Re: Remove trailing zeros

2009-02-27 Thread Matt Jones

The %g specifier to sprintf will do this automatically:

%g % 1.0
= 1

%g % 1.375
= 1.375

--Matt Jones

On Feb 27, 1:20 am, northband northb...@gmail.com wrote:
 Hi -

 I am working with floats and am wondering how I can trim the decimal
 and trailing zeros on my whole numbers.  For instance, whole numbers
 are being displayed as 1.0, 2.0, 3.0, etc...  I would like to remove
 the decimal and any trailing zeros with out effecting other non-whole
 number floats (ex. 1.375).

 Any ideas?  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-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: advise request: plugin routes with version prefix

2009-02-27 Thread Jean-Marc (M2i3.com)

Hi Raphaël,

Changing the version of an API is never just about the version, the
implications are more often than not pretty deep.

My take on your case would be to publish your application as the
version itself, not clouding each version with overly complex code to
handle version specific code and version specific transformations...

Right now it might seem as 2 version... how about in 5 years from
now...

So, instead of having:

connect '/rest/simple/v1/:controller/:action/:id'
connect '/rest/simple/v2/:controller/:action/:id'

You would have:
connect '/rest/simple/:controller/:action/:id'

in two different applications

Food for thoughts... but no matter what you determine... post it there
so we can all learn for your reflection!

have a good day!

Jean-Marc
http://m2i3.com

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



[Rails] Re: rails find :conditions seems to remove extra blanks? (e.g. where description = 'x x x x x') is this a rails bug?

2009-02-27 Thread Matt Jones

The log entries get passed through .squeeze(' '), I'm guessing to make
them look nicer on
the log. (activerecord/lib/active_record/connection_adapters/
abstract_adapter.rb, line 189)

Otherwise, I can't see anywhere in the code that's dropping the
spaces. Google's formatting
engine chews up spaces pretty bad, but are you *sure* you've got the
same number in
that second query?

On an unrelated note, are you really sure you want a fixed-width space-
delimited field in the DB?
Wouldn't it be easier to use multiple fields?

--Matt Jones

On Feb 26, 10:16 pm, Greg Hauptmann greg.hauptmann.r...@gmail.com
wrote:
 Hi,
 Is this a Rails bug?

 NORMAL SQL
 ? AccountItem.find_by_sql( select * from account_items where description =
 'FISHERS IGA HAMILTON     HAMILTON     AU 000318')
 = [#AccountItem id: 1100, account_id: 5, recurring_id: nil, date:
 2008-12-30, amount: #BigDecimal:24fc840,'-0.4E3',4(12), balance:
 #BigDecimal:24fc69c,'0.745538E4',8(12), description: FISHERS IGA HAMILTON
     HAMILTON     AU 000318, notes: nil, projection: false, created_at:
 2009-02-08 22:29:25, updated_at: 2009-02-08 22:29:25]



 WITH FINDER - DOES FIND THE RECORD
 ? AccountItem.find(:all, :conditions = [description = ?, 'FISHERS IGA
 HAMILTON     HAMILTON     AU 000318'] )
 = []
 EXTRACT FROM SERVER LOG - THE CREATED SQL SEEMS TO BE MISSING THE EXTRA
 SPACES??
    [4;36;1mAccountItem Load (3.0ms) [0m    [0;1mSELECT * FROM
 `account_items` WHERE (description = 'FISHERS IGA HAMILTON HAMILTON AU
 000318') [0m

 That is find method seems to be mis-translating the SQL and removing spaces.

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



  1   2   >