[Rails] Re: behavior of find(:select => ...)

2010-01-03 Thread bramu...@gmail.com
Super explanation and thank you very much On Jan 3, 8:46 pm, Rick DeNatale wrote: > On Sun, Jan 3, 2010 at 4:27 AM, acreadinglist wrote: > > Can someone clarify what type of object is returned from a find > > (:select => ...) statement that only selects a subset of the records > > columns? > > >

[Rails] How to avoid code duplication when validating virtual attributes?

2010-01-03 Thread Ben Teese
I recently had to do some work populating a model from complex virtual attributes. However, I also wanted to be able to leverage the validations framework to be able to add descriptions of errors that existed in virtual attribute values. I'm wondering how to avoid duplication between the code that

[Rails] Re: Restful routes

2010-01-03 Thread Rong
This is not a real app. so stuff your perversion and top posting. I got this from RailsCasts http://railscasts.com/episodes/35-custom-rest-actions On Jan 3, 1:07 pm, Marnen Laibow-Koser wrote: > Ron Green wrote: > > The correct answer is: > > > map.resources :pages, :collection => {:home => :get,

[Rails] Re: Question regarding entering data in a has_many relations

2010-01-03 Thread Simone R.
Ooh_Gravy wrote: > So answering my own question, is this ok or is there a cleaner way to > do it? > > > <% index = 1 %> > <% @recipe.steps.each do |step| %> > <%= index %>: <%= step.step %> > <% index += 1 %> > <% end %> > > > Thanks a lot. You can use the OL (orde

Re: [Rails] Re: model in subfolder, not missing constant error

2010-01-03 Thread Corin
Same backtrace without line breaks (hopefully): --- /var/lib/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:417:in `load_missing_constant' /var/lib/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:80:in `const_missing'

[Rails] Re: model in subfolder, not missing constant error

2010-01-03 Thread wakathane
On Jan 3, 5:33 pm, Matt Jones wrote: > > Historically, models in subfolders have caused problems, but they > should work now. Can you post a complete stack trace for either of > these errors? > > --Matt Jones Hi Matt, here's the full backtrace: /var/lib/gems/1.8/gems/activesupport-2.3.5/lib/a

Re: [Rails] Testing get :new

2010-01-03 Thread Curtis Jennings Schofield
maybe it is expecting this?? {:review => {:site_id => 10005}} On Sun, Jan 3, 2010 at 6:45 PM, Vincent P wrote: > I have a RESTful :new method to present a form.  I have implemented > this new method to use a params value params[:site_id].  For example, > the URL to this form would b

[Rails] Testing get :new

2010-01-03 Thread Vincent P
I have a RESTful :new method to present a form. I have implemented this new method to use a params value params[:site_id]. For example, the URL to this form would be : http://localhost:3000/reviews/new?site_id=1005 Now I need to test this new method. How do I put in the params value in the test?

[Rails] Re: RESTful new method

2010-01-03 Thread Vincent P
I finally figured out that I need to pass these things through params. Thanks. On Dec 31 2009, 11:48 am, "Easebus" wrote: > Thanks Robert.  Unfortunately, I already implemented the site model not > using REST and the review model as REST but standing alone not belonging to > another REST model.

Re: [Rails] Zip Code/Leading Zero's search problem

2010-01-03 Thread Curtis Jennings Schofield
Ahh Jason - Thank you - If i understand your problem in correctly - you wanted to turn the value into the database into a non-zipcode format to allow for people to search without including the leading zero? Also - thank you for the information about zero being a leading diget for zip codes. On

[Rails] Re: SQLServer on Rails

2010-01-03 Thread Damjan Rems
Leonardo Mateo wrote: > On Sun, Jan 3, 2010 at 4:10 PM, steve wrote: >> Does any one know how to setup SQLserver with ruby1.9. �It was working >> on an earlier version and now nothing works! �I have installed the >> gems dbi ,dbd-odbc and activerecord-odbc-adapter and can connect in >> straight Ru

[Rails] Re: model in subfolder, not missing constant error

2010-01-03 Thread Matt Jones
On Jan 2, 8:21 pm, Corin wrote: > Hi all, > > I'm using the latest rails 2.3.5 and put some models in subfolders like > this: > > models/my/details/texts.rb > models/my/details/attributes.rb > ... > > The models themselves are defined like this: > > class My::Details::Texts < ActiveRecord::Base

Re: [Rails] Zip Code/Leading Zero's search problem

2010-01-03 Thread Jason Soo
I ended up solving the problem using Philip's solution (thanks). Curtis, thanks for the recommendation, but zero is a valid leading value for some zip codes, so only doing a range of 1-9 wouldn't be as tight of a check as I would've liked. Thank you all for your help and replies. --- Jason Soo "I

Re: [Rails] Zip Code/Leading Zero's search problem

2010-01-03 Thread Curtis Jennings Schofield
be more explicit in your reg exp ie the first numeric must be [1-9] On Sun, Jan 3, 2010 at 1:36 PM, Jason Soo wrote: > Regex fails on validation even. > Plus just saying reg exp is not very helpful.  I'm not sure how to trap the > call before it reaching sql (assuming that is the best way to do

[Rails] small problem..

2010-01-03 Thread radu puspana
Sry for the trick but i had to do it. I just wanna wish everybody that takes a little or more of their time to help out, a noob or an expert, but especially the first ones, Happy New Year and NOTHING BUT THE BEST IN THE NEW YEAR.I really appreciate all the help i get from this wonderful and giving

Re: [Rails] Zip Code/Leading Zero's search problem

2010-01-03 Thread Philip Hallstrom
On Jan 3, 2010, at 12:02 PM, jsoo wrote: > Hey > > I'm running into an small issue with searching a zip codes table, > where some zip codes contain 1 or more leading zeros. This problem > could be fixed with some database level hacking -- but I'd rather > attack the problem in rails. > > Zip cod

Re: [Rails] Zip Code/Leading Zero's search problem

2010-01-03 Thread Jason Soo
Regex fails on validation even. Plus just saying reg exp is not very helpful. I'm not sure how to trap the call before it reaching sql (assuming that is the best way to do it) which is really what I'm trying to figure out. Sidebar: validates_format_of :zip_code, :with => /\A[0-9]{5}\Z/i, fai

Re: [Rails] Zip Code/Leading Zero's search problem

2010-01-03 Thread tom
reg exp On Sun, Jan 3, 2010 at 3:02 PM, jsoo wrote: > Hey > > I'm running into an small issue with searching a zip codes table, > where some zip codes contain 1 or more leading zeros.  This problem > could be fixed with some database level hacking -- but I'd rather > attack the problem in rails.

[Rails] Zip Code/Leading Zero's search problem

2010-01-03 Thread jsoo
Hey I'm running into an small issue with searching a zip codes table, where some zip codes contain 1 or more leading zeros. This problem could be fixed with some database level hacking -- but I'd rather attack the problem in rails. Zip codes are stored in the zip code table with leading zeros dr

[Rails] Same model multiple times, dynamically, in one form?

2010-01-03 Thread AlwaysCharging
I just can't seem to figure this out. I can do this no problem using each_with_index and iterating through an array set up in the controller's "New." But that only allows me to finite number of records. I'd like for the user to be able to dynamically pick the number records just by clicking "Add

Re: [Rails] SQLServer on Rails

2010-01-03 Thread Leonardo Mateo
On Sun, Jan 3, 2010 at 4:10 PM, steve wrote: > Does any one know how to setup SQLserver with ruby1.9.  It was working > on an earlier version and now nothing works!  I have installed the > gems dbi ,dbd-odbc and activerecord-odbc-adapter and can connect in > straight Ruby.  However, using rails wi

[Rails] Ruby and Rails OS environment documentation

2010-01-03 Thread Dale Ackerman
I am new and looking for some documentation about the OS evironment (variables) set and used by Ruby, Gems, and Rails. I want to understand how to configure and troubleshoot installations and integrations with other services HTTPD, SQL etc.. What Paths are required? What other environment variabl

[Rails] Re: login generator error, any login generate sure for ROR 2.0.2

2010-01-03 Thread Sukumaran Ammangod
Franco Sellitto wrote: > Hi > > The ROR 2.0.2 templates have now the .html.erb extension (the .rhtml is > the old one). > In order to solve your problem you have two solutions: > > a) modify the generator script directly on your gem directory (not > recommended) > > or > > b) copy your genera

[Rails] SMS Messaging

2010-01-03 Thread Merrick Christensen
Forgive this mis targeted email, I didn't know where else to send it to be truthful. I am building an application using Ruby on Rails, I need to know what SMS based service Highrise is using or something similar. Anyone have experience sending sms messages from Rails? I would love a link to a good

[Rails] SQLServer on Rails

2010-01-03 Thread steve
Does any one know how to setup SQLserver with ruby1.9. It was working on an earlier version and now nothing works! I have installed the gems dbi ,dbd-odbc and activerecord-odbc-adapter and can connect in straight Ruby. However, using rails with database.yml nothing works! I hosed everything and

[Rails] Re: Restful routes

2010-01-03 Thread Marnen Laibow-Koser
Ron Green wrote: > The correct answer is: > > map.resources :pages, :collection => {:home => :get, :about > => :get, :contact => :get } > > and then the link_to becomes: > > <%= link_to 'About', about_pages_path%> This is a bit of a perversion of map.resources. You probably want to just consi

[Rails] Re: Restful routes

2010-01-03 Thread Rong
The correct answer is: map.resources :pages, :collection => {:home => :get, :about => :get, :contact => :get } and then the link_to becomes: <%= link_to 'About', about_pages_path%> On Jan 2, 9:41 pm, Thais Camilo wrote: > And how about your Page Controller, did you change it to About Controlle

Re: [Rails] Re: Question regarding entering data in a has_many relations

2010-01-03 Thread Steve Klabnik
You would want each_with_index. <% @recipie.steps.each do |step, index| %> <%= index %>: <%= step.step %> <% end %> A little cleaner, and handles updating the index for you. -Steve On Sun, Jan 3, 2010 at 12:47 PM, Ooh_Gravy wrote: > So answering my own question, is this ok or i

[Rails] Re: Named Scopes and Created At

2010-01-03 Thread Frederick Cheung
On Jan 3, 5:14 pm, jm wrote: >   Post Load (0.4ms)   SELECT * FROM "posts" INNER JOIN "posts_tags" ON > "posts".id = "posts_tags".post_id WHERE ("posts_tags".tag_id = 1 ) AND > (("posts"."published" = 't') AND ("posts_tags".tag_id = 1 )) ORDER BY > posts.created_at DESC This is probably the que

[Rails] Re: ferret search in production

2010-01-03 Thread Frederick Cheung
On Jan 3, 5:39 pm, RubyonRails_newbie wrote: > Yes - it's installed: > already installed: acts_as_ferret (svn://projects.jkraemer.net/ > acts_as_ferret/tags/stable/acts_as_ferret).  pass --force to reinstall > > When I tried to start it: > script/ferret_server -e production start > > the server

[Rails] Re: Question regarding entering data in a has_many relations

2010-01-03 Thread Ooh_Gravy
So answering my own question, is this ok or is there a cleaner way to do it? <% index = 1 %> <% @recipe.steps.each do |step| %> <%= index %>: <%= step.step %> <% index += 1 %> <% end %>

[Rails] Re: ferret search in production

2010-01-03 Thread RubyonRails_newbie
Yes - it's installed: already installed: acts_as_ferret (svn://projects.jkraemer.net/ acts_as_ferret/tags/stable/acts_as_ferret). pass --force to reinstall When I tried to start it: script/ferret_server -e production start the server returned: -bash: script/ferret_server: Permission denied Hmmm

Re: [Rails] ferret search in production

2010-01-03 Thread Colin Law
2010/1/3 RubyonRails_newbie : > Hi there, > > after recently deploying my app, I have noticed that the search > results are not being displayed... > > When I look in my app, I also notice that the apps content (search > criterea) is not being indexed, so I dont have an index folder being > created.

[Rails] Re: ferret search in production

2010-01-03 Thread RubyonRails_newbie
Bit more info - looking at the ferret log file it says this: [user] DRb connection error: druby://localhost:9010 - # this tells me i've not configured something, but i'm still unsure how to resolve this... Any help appreciated... Thanks again On 3 Jan, 17:09, RubyonRails_newbie wrote: > Hi t

[Rails] Re: Named Scopes and Created At

2010-01-03 Thread jm
Thanks for the replies. Unfortunately, neither of the solutions worked. I tried each on their own with no luck, and then I combined the two suggestions and still no luck. Here is what I have for the named scope in my Post model as of now: named_scope :recently_published, :conditions => { :publish

[Rails] Re: Question regarding entering data in a has_many relations

2010-01-03 Thread Ooh_Gravy
OK, thanks. What I wanted to do was this: <% @recipe.steps.each do |step| %> <%= step.id %>: <%= step.step %> <% end %> but that would now result in: * 1: This is the first step * 3: This is the second step So I now ne

[Rails] ferret search in production

2010-01-03 Thread RubyonRails_newbie
Hi there, after recently deploying my app, I have noticed that the search results are not being displayed... When I look in my app, I also notice that the apps content (search criterea) is not being indexed, so I dont have an index folder being created. I read on a google post that it may be tha

[Rails] Re: Noob question .each problem

2010-01-03 Thread Frederick Cheung
On Jan 3, 4:37 pm, radu puspana wrote: > user.each do |correct_user| >    expected_password = User.encrypted_password(password, correct_user.salt) >    if correct_user.hashed_password == expected_password >        idx = user.index(correct_user) >return user[idx] >     end > end This is

[Rails] Re: Noob question .each problem

2010-01-03 Thread radu puspana
problem solved!!! thx to me :) On Jan 3, 6:37 pm, radu puspana wrote: > First, A Happy New Year to you all > Second : > > this is my login action form the admin controller: > def login >     if request.post? >       user = User.authenticate(params[:name], params[:password]) >       if user >    

[Rails] Noob question .each problem

2010-01-03 Thread radu puspana
First, A Happy New Year to you all Second : this is my login action form the admin controller: def login if request.post? user = User.authenticate(params[:name], params[:password]) if user if user.banned_status == "true" flash.now[:notice] = "We are sorry.You can

Re: [Rails] behavior of find(:select => ...)

2010-01-03 Thread Rick DeNatale
On Sun, Jan 3, 2010 at 4:27 AM, acreadinglist wrote: > Can someone clarify what type of object is returned from a find > (:select => ...) statement that only selects a subset of the records > columns? > > If I have an object Foo with attributes A and B, and call find(:select > => "A"), is the obje

Re: [Rails] Re: Question regarding entering data in a has_many relations

2010-01-03 Thread Rodrigo Dellacqua
Gravy, If I now delete the second step and add another I now have id's 1 and 3. id > 2 > has been 'consumed' which means that a simple loop using the id's to > generate an html list won't work. > Answering both of your questions, that's how the DB works. It has an internal sequence, which it inc

Re: [Rails] Re: Oracle adapter problem? How to fix this?

2010-01-03 Thread Rodrigo Dellacqua
Awesome! :) Pepe, thanks for letting us know about it. Gotta love RoR community, thanks Raimonds, kudos! []'s Rodrigo Dellacqua On Sun, Jan 3, 2010 at 9:01 AM, Raimonds Simanovskis < raimonds.simanovs...@gmail.com> wrote: > Original Oracle adapter is not maintained anymore since Rails 2.0 when

Re: [Rails] Re: script/generate cucumber fails in Rails 2.3.5 and Ruby 1.9.1

2010-01-03 Thread Rodrigo Dellacqua
Chris/Eric, Thanks both of you. Well, what happens is that I was using RubyMine which promptly asks you, if you want to install gems that are missing or just install gems from their interface. It ends up that RubyMine doesn't correctly install the gems. When I tried to list the available actions

[Rails] Re: Sessions

2010-01-03 Thread Frederick Cheung
On Jan 3, 12:35 pm, Ralph Shnelvar wrote: >  Cookies can have expiry dates set long in the > > > future, but sessions are handled with cookies that are set to only > > last until the browser quits (not the same as just closing a window). > > Let's say that I'm using Firefox and I open multiple i

[Rails] Re: Oracle adapter problem? How to fix this?

2010-01-03 Thread Raimonds Simanovskis
Original Oracle adapter is not maintained anymore since Rails 2.0 when it was taken out of Rails core. Therefore always please use oracle_enhanced adapter (http://github.com/ rsim/oracle-enhanced) which I maintain to be compatible with latest Rails releases and which we use in many production appl

[Rails] Re: Question regarding entering data in a has_many relations

2010-01-03 Thread Ooh_Gravy
OK, so my previous errors seemed to be due to a Windows environment issue. Now I'm back on my Mac things are all working. Anywaythanks for the help and pointing in the direction of those screencasts. I found Ryan's updated nested form example on Github (complex-form-examples) and it's just wh

Re: [Rails] Re: Sessions

2010-01-03 Thread Nicolai Constantin Reuschling
Hi Ralph, start here: http://guides.rubyonrails.org/action_controller_overview.html#session Regards, Nicolai -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To uns

[Rails] Re: Sessions

2010-01-03 Thread Ralph Shnelvar
Cookies can have expiry dates set long in the > future, but sessions are handled with cookies that are set to only > last until the browser quits (not the same as just closing a window). Let's say that I'm using Firefox and I open multiple instances of Firefox ... so do all the instances of Fire

[Rails] Re: Namespaced Controller and Model Access

2010-01-03 Thread Nicholas Young
Alright, so I fixed my problem, and wanted to post it here for anyone else that might be having the same issue. Basically, I just prefixed my model classes with two colons, like so: @node = ::Node.new This forces the namespaced controller to look for the model in the standard model directory. On

[Rails] Re: Underscore in a model's method causes it not to be called from the form helper

2010-01-03 Thread wdic...@googlemail.com
Hi, On 3 Jan., 00:21, Frederick Cheung wrote: > On Jan 2, 9:50 pm, "wdic...@googlemail.com" > wrote: > > > my Game#pconfig_src method will not be called. > > But if I change the method's name to 'pconfigsrc' and the symbol's > > name accordingly, then it is called. > > Why? > > Well when the met

[Rails] Problem with downloading a generated Excel sheet

2010-01-03 Thread Ahmed Abdelsalam
Hello, I'm using the spreadsheet/excel gem to generate an excel sheet that I want user to be able to download it once it's generated. Please take a look on the below code: @contacts=Contact.find(:all) if @contacts.size>0 file="#{Date.today}_Report.xls" workbook=Spreadsheet:

[Rails] Re: behavior of find(:select => ...)

2010-01-03 Thread Frederick Cheung
On Jan 3, 9:27 am, acreadinglist wrote: > Can someone clarify what type of object is returned from a find > (:select => ...) statement that only selects a subset of the records > columns? Foo.find always returns instances of Foo. That instance may have extra attributes, it may have fewer attrib

[Rails] behavior of find(:select => ...)

2010-01-03 Thread acreadinglist
Can someone clarify what type of object is returned from a find (:select => ...) statement that only selects a subset of the records columns? If I have an object Foo with attributes A and B, and call find(:select => "A"), is the object that's returned still a Foo object? Is it a new Foo object?

Re: [Rails] Restful routes

2010-01-03 Thread Thais Camilo
And how about your Page Controller, did you change it to About Controller? In your first implementation you've used Pages Controller to create your About page. If you didn't change it to and About Controller you can to do something loke that: map.resources :pages, :member => { :about => :get } [

[Rails] Re: Sessions

2010-01-03 Thread Frederick Cheung
On Jan 3, 4:46 am, Ralph Shnelvar wrote: > The *Agile Web Development with Rails* book has an explanation of > sessions that I am having trouble following. > > Does anyone know of another good discussion of how Rails manages > sessions. > > Specifically, in Firefox and and Internet Explorer ...

[Rails] Re: Best Practice setup Development environment OS X and Li

2010-01-03 Thread Marnen Laibow-Koser
Marnen Laibow-Koser wrote: > Ritchie Young wrote: >> On Jan 3, 3:47�pm, Marnen Laibow-Koser wrote: >> >>> > One other thing why PostgreSQL? >>> >>> Lots of reasons. �Performance, extensibility, adherence to the SQL >>> standard...MySQL is inferior in nearly every respect. >>> >> Ok, but what if y

[Rails] Re: Best Practice setup Development environment OS X and Li

2010-01-03 Thread Marnen Laibow-Koser
Ritchie Young wrote: > On Jan 3, 3:47�pm, Marnen Laibow-Koser wrote: > >> > One other thing why PostgreSQL? >> >> Lots of reasons. �Performance, extensibility, adherence to the SQL >> standard...MySQL is inferior in nearly every respect. >> > Ok, but what if you wanted to take advantage of some e

[Rails] Re: Best Practice setup Development environment OS X and Li

2010-01-03 Thread Ritchie
On Jan 3, 3:47 pm, Marnen Laibow-Koser wrote: > > One other thing why PostgreSQL? > > Lots of reasons.  Performance, extensibility, adherence to the SQL > standard...MySQL is inferior in nearly every respect. > Ok, but what if you wanted to take advantage of some existing managed infrastructure,