[Rails] Re: Rails 3.0, setting asset_host class

2010-09-05 Thread Kyle
Ok, thanks. I think I'll put it in an initializer, actually, as that's where it seems most of the configuration is headed to. On Sep 2, 3:11 pm, Chris Mear wrote: > On 2 September 2010 02:32, Kyle wrote: > > > > > I am upgrading to Rails 3.0, but am having a difficult time getting it > > to boo

[Rails] Re: reload! not working

2010-09-05 Thread badnaam
Nevermind turns out my model classname was same as the class name of a plugin. Wonder why reload! always returned true, never complained or gave a clue On Sep 5, 11:15 pm, badnaam wrote: > This is only happening for one model only! > > Here is the model. > > If I exit the console then start it ag

[Rails] Re: reload! not working

2010-09-05 Thread badnaam
This is only happening for one model only! Here is the model. If I exit the console then start it again the model updates load just fine. On Sep 5, 9:38 pm, badnaam wrote: > Not sure what happened but all of a sudden reload! stopped loading > updated model classes in irb. Anyone seen this? -

[Rails] When to use self.class.function vs self.function

2010-09-05 Thread pipplo
Hi Guys, I'm experimenting with my first rails app currently. One thing I'm trying to implement is a login system. I created a model for user.rb I've added a couple of functions to the class for example: def self.authenticate(user_info) find_by_username_and_password(, self.hashed_passwo

[Rails] reload! not working

2010-09-05 Thread badnaam
Not sure what happened but all of a sudden reload! stopped loading updated model classes in irb. Anyone seen this? -- You received 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

Re: [Rails] Re: its easy but i forgot all

2010-09-05 Thread rajeevsharma86
I have two modelds 1. loan model belongs_to :borrower 2. borrower model has_many:loans In my borrower Show method i wrote <%= link_to 'Request New Loan', :controller => 'loans', :action => 'new', :id => @borrower.id %> my loans_controller have this def new @borrower = Borrower.f

[Rails] Re: Cannot seem to display Comments on User Show Page

2010-09-05 Thread Kelp Kelp
Kelp Kelp wrote: > Fernando Perez wrote: >> You almost have it all correct, just in your view: >> >> <%= form_for([...@article, @comment]) do |f| %> >> >> >> -- >> >> http://digiprof.tv > > That worked excellently. > > I have one more question about the same set of files. I want to add a > l

[Rails] Re: Rails 3, help controlling access to a record based on the user id

2010-09-05 Thread nobosh
Thanks for the reply, I do have the relationships declared above in the models... I've been learning and following the rails 3 book here: http://railstutorial.org/chapters/a-demo-app#sec:microposts_resource I tried your suggestion "@note = @user ? @user.notes.find(params[:id]) : nil " and while it

[Rails] Re: Rails 3, help controlling access to a record based on the user id

2010-09-05 Thread Ed
On Sep 5, 10:53 pm, nobosh wrote: > Ed thanks for the reply. I'd love to hear more... I tried your > suggestion but it error'd: > > "undefined method `Notes' for nil:NilClass" > Two possible issues: 1. Do you have the relationship declared in the models? class Note < ActiveRecord belongs_t

[Rails] Re: Rails 3, help controlling access to a record based on the user id

2010-09-05 Thread nobosh
Ed thanks for the reply. I'd love to hear more... I tried your suggestion but it error'd: "undefined method `Notes' for nil:NilClass" On Sep 5, 6:50 pm, Ed wrote: > The cleanest method is to scope your notes by user instead of > searching the whole class: > > @note = @user.notes.find(params[:id]

[Rails] Need an online payment system - suggestions required

2010-09-05 Thread Christian Fazzini
Hello all, We are about to launch our site. One of the features that is missing at the moment is a way for users to fill in their credit card details and click send to purchase our products that we offer on our website. We are relatively new to this concept, so we do not know where to start? I am

[Rails] Re: Rails 3, help controlling access to a record based on the user id

2010-09-05 Thread Ed
The cleanest method is to scope your notes by user instead of searching the whole class: @note = @user.notes.find(params[:id]) On Sep 5, 7:25 pm, nobosh wrote: > This hack ends up working. Is there a cleaner, ruby trick to getting > this to work? > >                         @note = Note.find(pa

[Rails] Re: Pass a value from controller to model

2010-09-05 Thread Ed
On Sep 5, 10:29 am, Pål Bergström wrote: > Pål Bergström wrote: > > It works. But how do I deal with a list as this? How do I set the > variable? > > @tests = Test.find(:all) > -- brute force: @tests.each {|test| test.key = cookies[:my_key]} Might be a more clever way to do it. -- You rece

Re: [Rails] How about the heroku

2010-09-05 Thread Ekin Han
Thank you very much. I will try to install Rails on my own machine. 2010/9/6 jason white > Welcome! >Unfortunately in order to develop in Rails you will need to install it > locally on your machine. There are a couple of options here. You can install > all of the necessary files native to

[Rails] nested routes question

2010-09-05 Thread Ed
Trying to convert my app (and brain) to RESTful routes from the old style. What is the accepted approach to nesting a resource within 2 other resources? Example: Models Person has_many :scores Contest has_many :scores Score belongs_to :person, :contest Routes resources :people do

Re: [Rails] batch processing question

2010-09-05 Thread Hassan Schroeder
On Sun, Sep 5, 2010 at 5:44 PM, badnaam wrote: > In my app a user can set the status of a Post to different flags like > 'v' - visible, 'd' - mark for delete etc. > > These flags are set via controller actions. > > I have a batch process that runs and cleans all the posts marked for > delete. > >

[Rails] batch processing question

2010-09-05 Thread badnaam
In my app a user can set the status of a Post to different flags like 'v' - visible, 'd' - mark for delete etc. These flags are set via controller actions. I have a batch process that runs and cleans all the posts marked for delete. Post.find(:all, :conditions => ['status = ?', 'd']).each do |

[Rails] Re: Cannot seem to display Comments on User Show Page

2010-09-05 Thread Kelp Kelp
Fernando Perez wrote: > You almost have it all correct, just in your view: > > <%= form_for([...@article, @comment]) do |f| %> > > > -- > > http://digiprof.tv That worked excellently. I have one more question about the same set of files. I want to add a link for editing the comments on the a

[Rails] How to use Rspec to test Comments?

2010-09-05 Thread Kelp Kelp
Hello, My comments are currently routed inside of my articles, so my routes file looks like the following: resources :articles do resources :comments end I am trying to write an Rspec test that tests whether or not guests (non-signed-in users) can comment on my articles with the following

[Rails] Re: Rails 3, help controlling access to a record based on the user id

2010-09-05 Thread nobosh
This hack ends up working. Is there a cleaner, ruby trick to getting this to work? @note = Note.find(params[:id]) @note_userid = @note.user_id @current_userid = current_user.id redirect_to(root_path) un

Re: [Rails] Installing rails on lucid lynx.

2010-09-05 Thread Fidel Viegas
Hi Mark, Apparently you can only update ruby gems from the repositories. What I have done was install it from source. Just grab the source and install it. It will overwrite the existing one. I don't know if anyone else has another solution, but that is the one I found. Hope that helps. Regards,

[Rails] Rails 3, help controlling access to a record based on the user id

2010-09-05 Thread nobosh
Hello, I'm a Rails newbie Here's what I'm trying to do I created a scaffold for notes (t.text :content, t.integer :user_id) What I want to do now is only allow user's to view notes that they created. ie (== user_id) In my /app/controllers/notes_controller.rb I have the following: cl

Re: [Rails] Re: Pass a value from controller to model

2010-09-05 Thread Colin Law
2010/9/5 Pål Bergström : > Pål Bergström wrote: >> I'm trying to pass a value from a cookie from the controller into model >> by using attr_accessor. But it doesn't work and I suspect I do something >> wrong. >> >> Is this on the right path? >> >> class Test < ActiveRecord::Base >> >>   attr_access

[Rails] Re: Error: uninitialized constant MysqlCompat::MysqlRes

2010-09-05 Thread Ben Chatelain
Kyle Fox wrote: > To fix this, specify ARCHFLAGS when you install the 'mysql' gem: > > sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql- > config=/usr/local/mysql/bin/mysql_config > > On Aug 27, 12:07�pm, Caleb Cullen Exactly the answer I needed. Thanks! -- Posted via http:/

[Rails] Re: Default value depending on the controller action

2010-09-05 Thread Vitaly
Oops, I'm sorry. I thought I answered to some open topic with this, and didn't know I started a new one. Well, thank you for you idea, Luke. I though about putting work with data to model, and I think you are right. As for empty field, I add validates to model to check that this field isn't empty,

[Rails] Re: Triggering Javascript from a Ruby form

2010-09-05 Thread Parker Selbert
A. Leek wrote: > I'm pretty sure I have all the information I need in the program, the > problem is getting it all together and I'm not sure if that's even > possible. Does anyone have ideas? It may be too narrowly supported for what your trying, but you can go to the HTML5 route. Check out the F

[Rails] Re: installing a fork of a gem from github?

2010-09-05 Thread Parker Selbert
Jeremy McAnally wrote: > Prepend the username. So in this case: > >gem install skippy-ec2onrails > > And make sure gems.github.com is a source. In the past I've pulled down the source, built the gem, installed it and then unpacked it to vendor/gems. I like this solution *a lot* more. Grea

[Rails] Rails 3 production with fastCGI

2010-09-05 Thread s6numid
Does someone know how to push project into live. Project is written on Rails 3 and uses ruby 1.9.2? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe fro

Re: [Rails] Rails and database connection pooling

2010-09-05 Thread Nick Sieger
On Sun, Sep 5, 2010 at 8:57 AM, Joshua Partogi wrote: > Hi all, > > I am interested to learn more about connection pooling in rails. Is there > any good articles about this? I want to know specifically how is connection > pooling in rails works. Does rails open one connection to the database for >

[Rails] Jquery post authenticity_token is not sent

2010-09-05 Thread Manos
I have installed jquery-ujs driver and include jquery script in my view. In my view I have the following function $(function () { $('#alert').click(function () { $.ajax({ type: "POST", data: ({ lat: this.getAttribute('data-lat'), lon: 22.3908355 }),

[Rails] Re: Whats a good way to avoid nil lookup errors

2010-09-05 Thread Ugis Ozols
Good call on that find_by_id. Noted to myself :) On 5 sept., 16:42, Rob Biedenharn wrote: > On Sep 5, 2010, at 9:30 AM, Simon Macneall wrote: > > > On Sun, 05 Sep 2010 21:21:25 +0800, Michael Pavling   > > wrote: > > >> @user = User.find(1) if User.exists?(1) > > >> I don't like doing two lookup

[Rails] Re: Rails 3 install on Ruby Enterprise

2010-09-05 Thread Charlie B99
Veera Sundaravel wrote: > May be this link will help you. > http://veerasundaravel.wordpress.com/2010/02/15/rails3-beta-installation/ > Still receive error installing rails: active model requires i18n When I try to sudo gem install i18n, it errors out because it requires RubyGems 1.3.6 or highe

[Rails] Re: Default value depending on the controller action

2010-09-05 Thread Luke Cowell
You're not really asking a question, but if you're looking for feedback on your code, I'm happy to provide my 2 cents. It appears that image_url just returns a string as a path to an image under /images/ on your web server. I would override the default accessor for image_url in your model code eg

[Rails] Re: Rails friendly Forex broker?

2010-09-05 Thread Jeff Pritchard
Fernando Perez wrote: > The thing is to make your rails app communicate with the broker's api. > Like any other webservice. There is nothing specific to trading except > the rails app will act as a daemon and will communicate all the time > with the web service. Thanks Fernando, Yeah, I get tha

[Rails] Re: yield, helpers with blocks, and double-output

2010-09-05 Thread Luke Cowell
I haven't tested this in rails3, but this is what I do to capture the output of a block in rails 2. #my_helper.rb if block_given? block_text = capture(&block) end #view_file.html.erb <% my_helper do %> ##anything output here is captured and returned to block_text <% end %> Hope that helps. I w

[Rails] Re: Rails friendly Forex broker?

2010-09-05 Thread Fernando Perez
The thing is to make your rails app communicate with the broker's api. Like any other webservice. There is nothing specific to trading except the rails app will act as a daemon and will communicate all the time with the web service. -- Posted via http://www.ruby-forum.com/. -- You received th

[Rails] Re: sqlite3/sqlite3_native (LoadError)

2010-09-05 Thread Dani Dani
Ok, found the problem causig this: I had to set --> gem 'sqlite3-ruby', '1.2.5', :require => 'sqlite3' in the Gemfile and comment out: gem 'sqlite3-ruby', :require => 'sqlite3' -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups

[Rails] Re: Whats a good way to avoid nil lookup errors

2010-09-05 Thread Christian Fazzini
Hi Paul. but wouldnt that redirect to users_path on any activerecord not found event? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group,

Re: [Rails] How about the heroku

2010-09-05 Thread jason white
Welcome! Unfortunately in order to develop in Rails you will need to install it locally on your machine. There are a couple of options here. You can install all of the necessary files native to your machine, install a packaged development environment such as Ruby Stack from bitnami, or by us

[Rails] Default value depending on the controller action

2010-09-05 Thread Vitaly
The solution that is good for me: <% if controller.action_name == 'new' %> <%= f.text_field :image_url, :value => 'no image' %> <% else %> <%= f.text_field :image_url %> <% end %> and then in index.erb set smth like that <%= product.image_url == 'no image'

[Rails] How about the heroku

2010-09-05 Thread Ekin Han
Hi all, I am new to rails and I do not want to install rails on my own machine. Finally I found that there is cloudy rails server that called heroku. Could you kindly tell me does that application is good enough for developing rails? Is that free? Does it work well? Thank you. Eason -- You

[Rails] Re: Formatting data before ActiveRecord insertion

2010-09-05 Thread Paul Philippov
You can manipulate data before saving it class User before_save :do_something def do_something // process music_tracks here end end PS: I do not know the purpose of your project, but in general, having a table of songs referred by id seems a better option to me. Song 1 => { band => "K

[Rails] Re: Whats a good way to avoid nil lookup errors

2010-09-05 Thread Paul Philippov
def show @user = User.find(params[:id]) rescue ActiveRecord::RecordNotFound redirect_to users_path, :alert => "This user does not exists" end -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonr

[Rails] Re: Determining who is calling a helper method

2010-09-05 Thread Matt Jones
On Sep 3, 2:55 am, proximal wrote: > On Sep 2, 10:52 pm, Colin Law wrote: > > > So in several form_for method calls you call is_disabled as part of > > building the parameters for the form_for, and you want is_disabled to > > automatically know the symbol in the first param of the form_for?  I

Re: [Rails] Re: Whats a good way to avoid nil lookup errors

2010-09-05 Thread Bill Walton
Hi Christian On Sun, Sep 5, 2010 at 9:38 AM, Christian Fazzini wrote: > So this would be the convention right? not by using rescue_from. Is > this right? Yes. When possible, avoid begin-rescue by using Ruby / Rails to return a value you can handle within the normal course of your application lo

[Rails] Re: Whats a good way to avoid nil lookup errors

2010-09-05 Thread Christian Fazzini
So this would be the convention right? not by using rescue_from. Is this right? On Sep 5, 9:42 pm, Rob Biedenharn wrote: > On Sep 5, 2010, at 9:30 AM, Simon Macneall wrote: > > > On Sun, 05 Sep 2010 21:21:25 +0800, Michael Pavling   > > wrote: > > >> @user = User.find(1) if User.exists?(1) > > >

[Rails] Re: Pass a value from controller to model

2010-09-05 Thread Pål Bergström
Pål Bergström wrote: > I'm trying to pass a value from a cookie from the controller into model > by using attr_accessor. But it doesn't work and I suspect I do something > wrong. > > Is this on the right path? > > class Test < ActiveRecord::Base > > attr_accessor :key > > key .. > > en

[Rails] Rails and database connection pooling

2010-09-05 Thread Joshua Partogi
Hi all, I am interested to learn more about connection pooling in rails. Is there any good articles about this? I want to know specifically how is connection pooling in rails works. Does rails open one connection to the database for every user that is connected or does every user share the same da

Re: [Rails] Re: Whats a good way to avoid nil lookup errors

2010-09-05 Thread Rob Biedenharn
On Sep 5, 2010, at 9:30 AM, Simon Macneall wrote: On Sun, 05 Sep 2010 21:21:25 +0800, Michael Pavling wrote: @user = User.find(1) if User.exists?(1) I don't like doing two lookups for one record, but it works What about @user = User.find(:first, :conditions => {:id => 1}) if (@user) blah

[Rails] Re: installing a fork of a gem from github?

2010-09-05 Thread nico itkin
Did you find a solution ? , i've the same problem -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from th

Re: [Rails] Re: Whats a good way to avoid nil lookup errors

2010-09-05 Thread Simon Macneall
What about @user = User.find(:first, :conditions => {:id => 1}) if (@user) blah, blah, blah end It's longer to type, but returns nil if the user doesn't exist. On Sun, 05 Sep 2010 21:21:25 +0800, Michael Pavling wrote: @user = User.find(1) if User.exists?(1) I don't like doing two look

Re: [Rails] Re: Whats a good way to avoid nil lookup errors

2010-09-05 Thread Michael Pavling
@user = User.find(1) if User.exists?(1) I don't like doing two lookups for one record, but it works -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe fr

[Rails] Restful_authentication sending email on each login

2010-09-05 Thread Dhaval Phansalkar
Hi All, I'm facing a strange problem. I've configured RA with default account activation email setting. All works fine but whenever user logs in, an email is sent saying your account is activated. This happens on each login. Can somebody help me out with this? I'm using ruby 1.8.7 and rails 2.3.8.

[Rails] Re: Whats a good way to avoid nil lookup errors

2010-09-05 Thread Christian Fazzini
Yes but, it will never reach "unless." The system fails after @user = User.find(1) since Active Record is trying to find a record that does not exists On Sep 5, 7:28 pm, Ugis Ozols wrote: > One of the solutions would be to use redirect_to and flash[:notice] > like: > > @user = User.find(1) > unle

[Rails] Installing rails on lucid lynx.

2010-09-05 Thread Mark Hannah
I am getting the following error when I try to install rails on lucid lynx :- m...@mark-laptop:~/code/ruby$ sudo gem install rails ERROR: Error installing rails: i18n requires RubyGems version >= 1.3.6 I have installed RubyGems1.9.1, but it seems that "gem" is still at version 1.3.5 :- m...@m

[Rails] Re: sqlite3/sqlite3_native (LoadError)

2010-09-05 Thread Dani Dani
Hi, the above appears when I do: C:\Rails\first_app>rails server C:/Ruby192/lib/ruby/gems/1.9.1/gems/sqlite3-ruby-1.3.1-x86-mingw32/lib/sqlite3.rb:6:in `require': no such file to load -- sqlite3/sqlite3_native (LoadError) Need hep. thanks. dani -- Posted via http://www.ruby-forum.com/. --

[Rails] undefined method `path' for Gem:Module (NoMethodError)

2010-09-05 Thread Dani Dani
Hi, when running - 'ruby setup.rb' I get the following error message: C:\rubygems-1.3.7>ruby setup.rb C:/rubygems-1.3.7/lib/rubygems/source_index.rb:68:in installed_spec_directories': undefined method `path' for Gem:Module (NoMethodError) Ruby version is ruby-1.9.2-p0. Any idea ? Thanks. Dani -

[Rails] Re: Whats a good way to avoid nil lookup errors

2010-09-05 Thread Ugis Ozols
One of the solutions would be to use redirect_to and flash[:notice] like: @user = User.find(1) unless @user flash[:notice] = "can't find user with given id" redirect_to users_path end I won't say it's the best but it's still a solution :) On 5 sept., 13:55, Christian Fazzini wrote: > When n

[Rails] Whats a good way to avoid nil lookup errors

2010-09-05 Thread Christian Fazzini
When navigating to: http://localhost:3000/users/12 Whats a good way of avoiding the error: "Couldn't find User with ID=12", which happens when i try to display a page of user_id 12 that doesnt exist in the database. Instead of showing the error. id like to show a page that says: "This user does n

[Rails] Re: sqlite3/sqlite3_native (LoadError)

2010-09-05 Thread nktokyo
Does the file exist? I can't help much on windows, but have resolved similar issues on UNIX with a full path, not a relative path. On Sep 5, 7:11 pm, Dani Dani wrote: > Hi, > here is some more information. I'm using windows xp, sp3. > Here is the content of the sqlite3.rb file where the error co

[Rails] Re: sqlite3/sqlite3_native (LoadError)

2010-09-05 Thread Dani Dani
Hi, here is some more information. I'm using windows xp, sp3. Here is the content of the sqlite3.rb file where the error comes from: = # support multiple ruby version (fat binaries under windows) begin RUBY_VERSION =~ /(\d+.\d+)/ requi

[Rails] (Resolved) Re: drop_receiving_element does not fire

2010-09-05 Thread nktokyo
This is now resolved. On Sep 5, 1:23 pm, nktokyo wrote: > I am trying drag and drop in RoR for the first time. > > What I want to achieve, is a list of slots, and a list of entries. You > should be able to drag an entry onto a slot and slot.entry_id will > update to match the dragged entry.ent

Re: [Rails] Formatting data before ActiveRecord insertion

2010-09-05 Thread Colin Law
On 5 September 2010 00:31, Tom Fielding wrote: > Hello, > Sorry if this is a noob question. > I'm trying to store a hash of values (a user's music collection) into a > single database record without having to have a separate row in the db for > each music track the user has in his collection. > e.

[Rails] Formatting data before ActiveRecord insertion

2010-09-05 Thread Tom Fielding
Hello, Sorry if this is a noob question. I'm trying to store a hash of values (a user's music collection) into a single database record without having to have a separate row in the db for each music track the user has in his collection. e.g. User 9 { 12319 => "Artist X: Song Name 1", 12198 =>

[Rails] drop_receiving_element does not fire

2010-09-05 Thread nktokyo
I am trying drag and drop in RoR for the first time. What I want to achieve, is a list of slots, and a list of entries. You should be able to drag an entry onto a slot and slot.entry_id will update to match the dragged entry.entry_id. I've spent a lot of time looking in textbooks and online, but

Re: [Rails] Pass a value from controller to model

2010-09-05 Thread Colin Law
2010/9/4 Pål Bergström : > I'm trying to pass a value from a cookie from the controller into model > by using attr_accessor. But it doesn't work and I suspect I do something > wrong. > > Is this on the right path? > > class Test < ActiveRecord::Base > >  attr_accessor :key > >   key .. > > end

Re: [Rails] Moving ROR Dev from one windows PC to another

2010-09-05 Thread Colin Law
On 4 September 2010 19:26, DMaster wrote: > Is it possible to move the complete ROR install/development directory > or directories to new PC and continue to work/dev as the original one? Yes, assuming you are talking about the rails application itself. You will also have to install the developme

[Rails] Help with routes

2010-09-05 Thread Christian Fazzini
In my view, I've got the following condition: <% if current_page? :controller => 'deals', :action => 'foobar' %> woot <% end %> My route looks like: map.fobar '/:city.:format', :controller => 'deals', :action => 'foobar', :defaults => { :format => 'html' } However, the conditions su

[Rails] Re: Pass a value from controller to model

2010-09-05 Thread Pål Bergström
Fernando Perez wrote: > It should work. What makes you think it doesn't? And it hasn't to be a column in the database (it isn't)? My solution didn't work. But when you say that it should I know I'm on the right track and that the problem is elsewhere. Thanks. -- Posted via http://www.ruby-forum