From mikkel at refsgaardbech.dk Sat May 2 16:04:36 2009 From: mikkel at refsgaardbech.dk (Mikkel Refsgaard Bech) Date: Sat, 2 May 2009 22:04:36 +0200 Subject: camping-test error: undefined method `fixtures' Message-ID: <665532BD-A546-45ED-ABC2-A5220AA110C1@refsgaardbech.dk> Hi Trying to use camping-test with my camping app but I get an error: undefined method `fixtures' The error can be reproduced by using this empty app (your_app.rb): require 'camping' Camping.goes :YourApp module Steps module Models end module Controllers end module Views end end And running the test from camping-test: http://github.com/judofyr/camping-test/tree/master I just run: # ruby test_your_app.rb test_your_app.rb:7: undefined method `fixtures' for YourApp::Tests::TestSomeBasicStuff:Class (NoMethodError) camping-1.9.300 activesupport-2.3.2 activerecord-2.3.2 camping-test Is anyone using this successfully? Regards, Mikkel From judofyr at gmail.com Sat May 2 17:54:32 2009 From: judofyr at gmail.com (Magnus Holm) Date: Sat, 2 May 2009 23:54:32 +0200 Subject: camping-test error: undefined method `fixtures' In-Reply-To: <665532BD-A546-45ED-ABC2-A5220AA110C1@refsgaardbech.dk> References: <665532BD-A546-45ED-ABC2-A5220AA110C1@refsgaardbech.dk> Message-ID: <8AF76F33-377E-4E68-9490-F699873206BC@gmail.com> Oh, didn't know anyone was actually using this :-) It's because Rails no longer include the fixture-model into Test::Unit::TestCase, but rather into a subclass. I'll see if I can fix it... //Magnus Den 2. mai. 2009 kl. 22.04 skrev Mikkel Refsgaard Bech : > Hi > > Trying to use camping-test with my camping app but I get an error: > undefined method `fixtures' > > The error can be reproduced by using this empty app (your_app.rb): > > require 'camping' > Camping.goes :YourApp > module Steps > module Models > end > module Controllers > end > module Views > end > end > > And running the test from camping-test: > http://github.com/judofyr/camping-test/tree/master > > I just run: > # ruby test_your_app.rb > test_your_app.rb:7: undefined method `fixtures' for > YourApp::Tests::TestSomeBasicStuff:Class (NoMethodError) > > camping-1.9.300 > activesupport-2.3.2 > activerecord-2.3.2 > camping-test > > Is anyone using this successfully? > > Regards, > Mikkel > > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list From judofyr at gmail.com Sun May 3 15:34:08 2009 From: judofyr at gmail.com (Magnus Holm) Date: Sun, 3 May 2009 21:34:08 +0200 Subject: camping-test error: undefined method `fixtures' In-Reply-To: <665532BD-A546-45ED-ABC2-A5220AA110C1@refsgaardbech.dk> References: <665532BD-A546-45ED-ABC2-A5220AA110C1@refsgaardbech.dk> Message-ID: <391a49da0905031234m61694bfdk36b8824004fbd478@mail.gmail.com> I've pushed out a fix now. Could you verify it? //Magnus Holm On Sat, May 2, 2009 at 22:04, Mikkel Refsgaard Bech wrote: > Hi > > Trying to use camping-test with my camping app but I get an error: > undefined method `fixtures' > > The error can be reproduced by using this empty app (your_app.rb): > > require 'camping' > Camping.goes :YourApp > module Steps > module Models > end > module Controllers > end > module Views > end > end > > And running the test from camping-test: > http://github.com/judofyr/camping-test/tree/master > > I just run: > # ruby test_your_app.rb > test_your_app.rb:7: undefined method `fixtures' for > YourApp::Tests::TestSomeBasicStuff:Class (NoMethodError) > > camping-1.9.300 > activesupport-2.3.2 > activerecord-2.3.2 > camping-test > > Is anyone using this successfully? > > Regards, > Mikkel > > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mikkel at refsgaardbech.dk Tue May 5 16:40:50 2009 From: mikkel at refsgaardbech.dk (Mikkel Refsgaard Bech) Date: Tue, 5 May 2009 22:40:50 +0200 Subject: camping-test error: undefined method `fixtures' In-Reply-To: <391a49da0905031234m61694bfdk36b8824004fbd478@mail.gmail.com> References: <665532BD-A546-45ED-ABC2-A5220AA110C1@refsgaardbech.dk> <391a49da0905031234m61694bfdk36b8824004fbd478@mail.gmail.com> Message-ID: <9ABC67F1-86E0-4430-9A72-CE7D25DB5627@refsgaardbech.dk> On 03/05/2009, at 21.34, Magnus Holm wrote: > I've pushed out a fix now. Could you verify it? Works fine, thank you. Any reason for not using the :memory: database any longer? Regards, Mikkel From judofyr at gmail.com Tue May 5 16:49:13 2009 From: judofyr at gmail.com (Magnus Holm) Date: Tue, 5 May 2009 22:49:13 +0200 Subject: camping-test error: undefined method `fixtures' In-Reply-To: <9ABC67F1-86E0-4430-9A72-CE7D25DB5627@refsgaardbech.dk> References: <665532BD-A546-45ED-ABC2-A5220AA110C1@refsgaardbech.dk> <391a49da0905031234m61694bfdk36b8824004fbd478@mail.gmail.com> <9ABC67F1-86E0-4430-9A72-CE7D25DB5627@refsgaardbech.dk> Message-ID: <391a49da0905051349k285085abi88b9a4b3b383c772@mail.gmail.com> Oh crap. Did that get commited? I was just testing if the memory-database had anything to do with it and forgot to change it back later. Pushing a "fix" tomorrow :-) //Magnus Holm On Tue, May 5, 2009 at 22:40, Mikkel Refsgaard Bech wrote: > On 03/05/2009, at 21.34, Magnus Holm wrote: > > I've pushed out a fix now. Could you verify it? >> > > Works fine, thank you. > > Any reason for not using the :memory: database any longer? > > > Regards, > Mikkel > > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From his2000x at gmail.com Wed May 6 05:34:57 2009 From: his2000x at gmail.com (in-seok hwang) Date: Wed, 6 May 2009 18:34:57 +0900 Subject: i want div's controller in layout fucntion Message-ID: hi! all! my camping version is . 1.5.180 mongrel is 1.1.5 Finally, my web site is almost complete. thank you! camper!!!!! but, i has one little problem. i know that how connect 'some page' and 'some controller'. In this case, how i can connect 'div ' and 'some controller' Sample code has a few modifications. require 'camping' > > Camping.goes :Blog > > module Blog::Models > class Post < Base; belongs_to :user; end > class Comment < Base; belongs_to :user; end > class User < Base; end > end > > module Blog::Controllers > class Index < R '/' > def get > @posts = Post.find :all > render :index > end > end > class News #point 2 > def get > p 'this is News get' > render :news > end > end > end > > module Blog::Views > def layout > html do > body do > div :id => 'news' do # point 1 > self << news > end > > div :id => 'content' do > self << yield > end > end > end > end > > def index > for post in @posts > h1 post.title > end > end > > def news #point 3 > ul do > li 'test1' > li 'test2' > li 'test3' > li 'test4' > end > end > > end > this code is can't connect News controller.( not print 'this is News get' ) i want connect point1 and point2 .... like a Index controller and change ul list(point3) Do not worry about if my article has typing miss -------------- next part -------------- An HTML attachment was scrubbed... URL: From judofyr at gmail.com Wed May 6 15:50:46 2009 From: judofyr at gmail.com (Magnus Holm) Date: Wed, 6 May 2009 21:50:46 +0200 Subject: i want div's controller in layout fucntion In-Reply-To: References: Message-ID: <391a49da0905061250v13a0bb71x3fa7cb1df76e8fa0@mail.gmail.com> Let me see if I understand your problem correctly:On every page you want to include news, which should go through the News-controller? Here's one way to do it: http://pastie.textmate.org/private/0a47n2wegu7xdaovoudu2q //Magnus Holm On Wed, May 6, 2009 at 11:34, in-seok hwang wrote: > hi! all! > > my camping version is . 1.5.180 > mongrel is 1.1.5 > > Finally, my web site is almost complete. > thank you! camper!!!!! > > but, i has one little problem. > > i know that how connect 'some page' and 'some controller'. > > In this case, how i can connect 'div ' and 'some controller' > > Sample code has a few modifications. > > require 'camping' >> >> Camping.goes :Blog >> >> module Blog::Models >> class Post < Base; belongs_to :user; end >> class Comment < Base; belongs_to :user; end >> class User < Base; end >> end >> >> module Blog::Controllers >> class Index < R '/' >> def get >> @posts = Post.find :all >> render :index >> end >> end >> class News #point 2 >> def get >> p 'this is News get' >> render :news >> end >> end >> end >> >> module Blog::Views >> def layout >> html do >> body do >> div :id => 'news' do # point 1 >> self << news >> end >> >> div :id => 'content' do >> self << yield >> end >> end >> end >> end >> >> def index >> for post in @posts >> h1 post.title >> end >> end >> >> def news #point 3 >> ul do >> li 'test1' >> li 'test2' >> li 'test3' >> li 'test4' >> end >> end >> >> end >> > > this code is can't connect News controller.( not print 'this is News get' ) > > i want connect point1 and point2 .... like a Index controller > and change ul list(point3) > > Do not worry about if my article has typing miss > > > > > > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From his2000x at gmail.com Wed May 6 16:53:58 2009 From: his2000x at gmail.com (in-seok hwang) Date: Thu, 7 May 2009 05:53:58 +0900 Subject: i want div's controller in layout fucntion In-Reply-To: <391a49da0905061250v13a0bb71x3fa7cb1df76e8fa0@mail.gmail.com> References: <391a49da0905061250v13a0bb71x3fa7cb1df76e8fa0@mail.gmail.com> Message-ID: thank you! Magnus Holm!!!! the problem has been resolved. finally , i can sleep :) have a nice day~ 2009/5/7 Magnus Holm : > Let me see if I understand your problem correctly: > On every page you want to include news, which should go through the > News-controller? > Here's one way to do > it:?http://pastie.textmate.org/private/0a47n2wegu7xdaovoudu2q > > //Magnus Holm > > > On Wed, May 6, 2009 at 11:34, in-seok hwang wrote: >> >> hi! all! >> >> my camping version is . 1.5.180 >> mongrel is 1.1.5 >> >> Finally, my web site is almost complete. >> thank you! camper!!!!! >> >> but, i has one little problem. >> >> i know that how connect 'some page' and 'some controller'. >> >> ?In this case, how i can connect 'div ' and 'some controller' >> >> Sample code has a few modifications. >> >>> ???? require 'camping' >>> >>> ????? Camping.goes :Blog >>> >>> ????? module Blog::Models >>> ??????? class Post < Base; belongs_to :user; end >>> ??????? class Comment < Base; belongs_to :user; end >>> ??????? class User < Base; end >>> ????? end >>> >>> ????? module Blog::Controllers >>> ??????? class Index < R '/' >>> ????????? def get >>> ??????????? @posts = Post.find :all >>> ??????????? render :index >>> ????????? end >>> ??????? end >>> ??????? class News?????????????? #point 2 >>> ????????? def get >>> ??????????? p 'this is News get' >>> ??????????? render :news >>> ????????? end >>> ??????? end >>> ????? end >>> >>> ????? module Blog::Views >>> ??????? def layout >>> ????????? html do >>> ??????????? body do >>> ????????????? div :id => 'news' do??????? # point 1 >>> ???????????????? self << news >>> ????????????? end >>> >>> ????????????? div :id => 'content' do >>> ???????????????? self << yield >>> ????????????? end >>> ??????????? end >>> ????????? end >>> ??????? end >>> >>> ??????? def index >>> ????????? for post in @posts >>> ??????????? h1 post.title >>> ????????? end >>> ??????? end >>> >>> ??????? def news?????????????? #point 3 >>> ????????? ul do >>> ???????????????????? li 'test1' >>> ???????????????????? li 'test2' >>> ???????????????????? li 'test3' >>> ???????????????????? li 'test4' >>> ?????????? end >>> ???????? end >>> >>> ????? end >> >> this code is can't connect News controller.( not print 'this is News get' >> ) >> >> i want? connect point1 and point2 .... like a Index controller >> and change ul list(point3) >> >> Do not worry about if my article has typing miss >> >> >> >> >> >> _______________________________________________ >> Camping-list mailing list >> Camping-list at rubyforge.org >> http://rubyforge.org/mailman/listinfo/camping-list > > > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list > From judofyr at gmail.com Thu May 7 05:06:44 2009 From: judofyr at gmail.com (Magnus Holm) Date: Thu, 7 May 2009 11:06:44 +0200 Subject: camping-test error: undefined method `fixtures' In-Reply-To: References: <665532BD-A546-45ED-ABC2-A5220AA110C1@refsgaardbech.dk> <391a49da0905031234m61694bfdk36b8824004fbd478@mail.gmail.com> <9ABC67F1-86E0-4430-9A72-CE7D25DB5627@refsgaardbech.dk> <391a49da0905051349k285085abi88b9a4b3b383c772@mail.gmail.com> Message-ID: <391a49da0905070206l3117ee65jf6bbc472215871c8@mail.gmail.com> That sounds like a good idea. I've figured out one way to do cookies, but still need to find a way to handle sessions. Pushing later when I've come up with something :-) //Magnus Holm On Wed, May 6, 2009 at 22:28, Mikkel Refsgaard Bech wrote: > > On 05/05/2009, at 22.49, Magnus Holm wrote: > > Oh crap. Did that get commited? I was just testing if the memory-database > had anything to do with it and forgot to change it back later. Pushing a > "fix" tomorrow :-) > > > Sweet. > > One other thing, I can't figure out how to input some @state before I call > get/post/etc... I need to test my app while I'm logged in, which just means > that some user ID is set in @state, is that possible? > > E.g.: > > test "i can get my secret page when I am logged id" do > @state.user_id = 1 > get '/secretpage' > assert_response :ok > end > > Thanks, > Mikkel > > > > //Magnus Holm > > > On Tue, May 5, 2009 at 22:40, Mikkel Refsgaard Bech < > mikkel at refsgaardbech.dk> wrote: > >> On 03/05/2009, at 21.34, Magnus Holm wrote: >> >> I've pushed out a fix now. Could you verify it? >>> >> >> Works fine, thank you. >> >> Any reason for not using the :memory: database any longer? >> >> >> Regards, >> Mikkel >> >> _______________________________________________ >> Camping-list mailing list >> Camping-list at rubyforge.org >> http://rubyforge.org/mailman/listinfo/camping-list >> > > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list > > > > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From deveritt at innotts.co.uk Sun May 17 18:02:19 2009 From: deveritt at innotts.co.uk (Dave Everitt) Date: Sun, 17 May 2009 23:02:19 +0100 Subject: No subject Message-ID: Hi after many attempts to get the sqlite3 examples running ("unable to open database file:"), I found this: "sqlite3-ruby won?t even link against your libsqlite3 unless SWIG is installed." (http://www.baconbear.com/articles/2006/12/06/osx-sqlite3-and-rails) Anyone shed any light on this? I'm running it as a cgi app (no problem with Camping itself, just any apps that need sqlite3) under Apache, OS X 10.4.11... sqlite 3.1.3 (the one that comes with the system and OS X uses)? Dave Everitt From deveritt at innotts.co.uk Mon May 18 05:22:57 2009 From: deveritt at innotts.co.uk (Dave Everitt) Date: Mon, 18 May 2009 10:22:57 +0100 Subject: sqlite3 connection problem In-Reply-To: References: Message-ID: <43ACD816-1465-4DEC-892E-40CEAD38EC40@innotts.co.uk> Regarding the post below: in case anyone was going to reply about SWIG, I checked and found this on the sqlite3-ruby GIT pages: "the gem ships with the C source-code pre-built, so (as of version 1.1.1) you no longer need to have SWIG installed." So my problem is obviously elsewhere... sqlite3 works fine, I'm using Ruby 1.8.6... will keep trying, unless anyone has helpful suggestions? I'm just getting my head around Camping, so it could well be me, somewhere... here's my Gem list: activerecord (2.3.2) activesupport (2.3.2) acts_as_versioned (0.2.3) builder (2.1.2) camping (1.5) cgi_multipart_eof_fix (2.5.0) cheat (1.2.1) daemons (1.0.10) fastthread (1.0.7, 1.0.1) gem_plugin (0.2.3) innate (2009.05) markaby (0.5) metaid (1.0) mongrel (1.1.5) rack (1.0.0, 0.4.0) ramaze (2009.05, 2008.11) rubygems-update (1.3.3, 1.3.1) sources (0.0.1) sqlite3-ruby (1.2.4) I'm wary of updating sqlite 3.1.3 to 3.6.10, as OS X uses it... just need to know if Camping has a problem with sqlite 3.1.3? I don't use ports, but happy to go /ursr/local. Dave Everitt > Hi > > after many attempts to get the sqlite3 examples running ("unable to > open database file:"), I found this: > > "sqlite3-ruby won?t even link against your libsqlite3 unless SWIG > is installed." > (http://www.baconbear.com/articles/2006/12/06/osx-sqlite3-and-rails) > > Anyone shed any light on this? > > I'm running it as a cgi app (no problem with Camping itself, just > any apps that need sqlite3) under Apache, OS X 10.4.11... sqlite > 3.1.3 (the one that comes with the system and OS X uses)? > > Dave Everitt From judofyr at gmail.com Mon May 18 08:29:29 2009 From: judofyr at gmail.com (Magnus Holm) Date: Mon, 18 May 2009 14:29:29 +0200 Subject: sqlite3 connection problem In-Reply-To: <43ACD816-1465-4DEC-892E-40CEAD38EC40@innotts.co.uk> References: <43ACD816-1465-4DEC-892E-40CEAD38EC40@innotts.co.uk> Message-ID: <391a49da0905180529v6843af88mad5a9a2b8c97e349@mail.gmail.com> Weird. I've used sqlite3 on the SQLite which follows with 10.4 earlier. Could you paste the code you use to connect to the database? //Magnus Holm On Mon, May 18, 2009 at 11:22, Dave Everitt wrote: > Regarding the post below: in case anyone was going to reply about SWIG, I > checked and found this on the sqlite3-ruby GIT pages: > > "the gem ships with the C source-code pre-built, so (as of version 1.1.1) > you no longer need to have SWIG installed." > > So my problem is obviously elsewhere... sqlite3 works fine, I'm using Ruby > 1.8.6... will keep trying, unless anyone has helpful suggestions? I'm just > getting my head around Camping, so it could well be me, somewhere... here's > my Gem list: > > activerecord (2.3.2) > activesupport (2.3.2) > acts_as_versioned (0.2.3) > builder (2.1.2) > camping (1.5) > cgi_multipart_eof_fix (2.5.0) > cheat (1.2.1) > daemons (1.0.10) > fastthread (1.0.7, 1.0.1) > gem_plugin (0.2.3) > innate (2009.05) > markaby (0.5) > metaid (1.0) > mongrel (1.1.5) > rack (1.0.0, 0.4.0) > ramaze (2009.05, 2008.11) > rubygems-update (1.3.3, 1.3.1) > sources (0.0.1) > sqlite3-ruby (1.2.4) > > I'm wary of updating sqlite 3.1.3 to 3.6.10, as OS X uses it... just need > to know if Camping has a problem with sqlite 3.1.3? I don't use ports, but > happy to go /ursr/local. > > Dave Everitt > > Hi >> >> after many attempts to get the sqlite3 examples running ("unable to open >> database file:"), I found this: >> >> "sqlite3-ruby won?t even link against your libsqlite3 unless SWIG is >> installed." >> (http://www.baconbear.com/articles/2006/12/06/osx-sqlite3-and-rails) >> >> Anyone shed any light on this? >> >> I'm running it as a cgi app (no problem with Camping itself, just any apps >> that need sqlite3) under Apache, OS X 10.4.11... sqlite 3.1.3 (the one that >> comes with the system and OS X uses)? >> >> Dave Everitt >> > > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From deveritt at innotts.co.uk Mon May 18 10:35:26 2009 From: deveritt at innotts.co.uk (Dave Everitt) Date: Mon, 18 May 2009 15:35:26 +0100 Subject: sqlite3 connection problem In-Reply-To: <391a49da0905180529v6843af88mad5a9a2b8c97e349@mail.gmail.com> References: <43ACD816-1465-4DEC-892E-40CEAD38EC40@innotts.co.uk> <391a49da0905180529v6843af88mad5a9a2b8c97e349@mail.gmail.com> Message-ID: <63CD8992-9F95-438C-A506-3F41BBE18125@innotts.co.uk> Many attempts (3 days now) to get even a single sqlite3 example running... I've got a little further by creating the database file from the sqlite3 shell. Now the app connects to an empty db and I get: ActiveRecord::StatementInvalid SQLite3::SQLException: no such table: blogtiny_posts: SELECT * FROM "blogtiny_posts" : I am I right to expect that Camping will create the necessary tables when run as CGI? > Weird. I've used sqlite3 on the SQLite which follows with 10.4 > earlier. Could you paste the code you use to connect to the database? > > //Magnus Holm > >> I'm running it as a cgi app (no problem with Camping itself, just >> any apps that need sqlite3) under Apache, OS X 10.4.11... sqlite >> 3.1.3 (the one that comes with the system and OS X uses)? >> >> Dave Everitt From dsusco at gmail.com Tue May 19 09:31:11 2009 From: dsusco at gmail.com (David Susco) Date: Tue, 19 May 2009 09:31:11 -0400 Subject: using redirect with a mongrel server behind apache Message-ID: <1bd79b4a0905190631o234323a5u8073eb41bda04b1b@mail.gmail.com> Not sure if this list is still active but I haven't found another yet, here's my setup and question. * I'm running a camping app using a mongrel server listening at 127.0.0.1:X. * I have a virtual host setup in Apache that is rewriting my_vhost.net/my_app/ to 127.0.0.1:X. * In one of my controllers I'm trying to redirect to another controller like this: redirect Index * Instead of being directed to my_vhost.net/my_app/ though the user is directed to 127.0.0.1:X. What's the best/cleanest way to get around this and have the controller redirect to my_vhost.net/my_app/? -- Dave From judofyr at gmail.com Tue May 19 10:21:43 2009 From: judofyr at gmail.com (Magnus Holm) Date: Tue, 19 May 2009 16:21:43 +0200 Subject: using redirect with a mongrel server behind apache In-Reply-To: <1bd79b4a0905190631o234323a5u8073eb41bda04b1b@mail.gmail.com> References: <1bd79b4a0905190631o234323a5u8073eb41bda04b1b@mail.gmail.com> Message-ID: <391a49da0905190721l1fe2dfc0y4dc0cb3c9892a15a@mail.gmail.com> Camping uses the Host-header to figure out where the app is located, and Apache *should* carry forward the header to the Mongrel. How have you set this up? If you're using Camping 1.9 or running this through Rack, you could always create a middleware which changes the Host-header: class Thing def initialize(app, options = {}) @app = app end def call(env) @app.call(env.merge({ 'HTTP_HOST' => 'my_vhost.net' })) end end app = Thing.new(app) ------- I also believe Apache is able to modify HTTP-headers. //Magnus Holm On Tue, May 19, 2009 at 15:31, David Susco wrote: > Not sure if this list is still active but I haven't found another yet, > here's my setup and question. > > * I'm running a camping app using a mongrel server listening at 127.0.0.1: > X. > * I have a virtual host setup in Apache that is rewriting > my_vhost.net/my_app/ to 127.0.0.1:X. > * In one of my controllers I'm trying to redirect to another > controller like this: redirect Index > * Instead of being directed to my_vhost.net/my_app/ though the user is > directed to 127.0.0.1:X. > > What's the best/cleanest way to get around this and have the > controller redirect to my_vhost.net/my_app/? > > -- > Dave > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From judofyr at gmail.com Tue May 19 10:25:14 2009 From: judofyr at gmail.com (Magnus Holm) Date: Tue, 19 May 2009 16:25:14 +0200 Subject: sqlite3 connection problem In-Reply-To: <63CD8992-9F95-438C-A506-3F41BBE18125@innotts.co.uk> References: <43ACD816-1465-4DEC-892E-40CEAD38EC40@innotts.co.uk> <391a49da0905180529v6843af88mad5a9a2b8c97e349@mail.gmail.com> <63CD8992-9F95-438C-A506-3F41BBE18125@innotts.co.uk> Message-ID: <391a49da0905190725v7d668156ib7840376924a2d8b@mail.gmail.com> In order to create the necessary tables you'll have to run Blogtiny::Models.create_schema. The prefered way is define a create-method like this: def Blogtiny.create Blogtiny::Models.create_schema end All servers or setups using Camping should then call Blogtiny.create on startup after the app is loaded (so yes, you still have to call this yourself). //Magnus Holm On Mon, May 18, 2009 at 16:35, Dave Everitt wrote: > Many attempts (3 days now) to get even a single sqlite3 example running... > I've got a little further by creating the database file from the sqlite3 > shell. Now the app connects to an empty db and I get: > > ActiveRecord::StatementInvalid SQLite3::SQLException: no such table: > blogtiny_posts: SELECT * FROM "blogtiny_posts" : > > I am I right to expect that Camping will create the necessary tables when > run as CGI? > > Weird. I've used sqlite3 on the SQLite which follows with 10.4 earlier. >> Could you paste the code you use to connect to the database? >> >> //Magnus Holm >> >> I'm running it as a cgi app (no problem with Camping itself, just any >>> apps that need sqlite3) under Apache, OS X 10.4.11... sqlite 3.1.3 (the one >>> that comes with the system and OS X uses)? >>> >>> Dave Everitt >>> >> _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dsusco at gmail.com Tue May 19 11:05:44 2009 From: dsusco at gmail.com (David Susco) Date: Tue, 19 May 2009 11:05:44 -0400 Subject: using redirect with a mongrel server behind apache In-Reply-To: <391a49da0905190721l1fe2dfc0y4dc0cb3c9892a15a@mail.gmail.com> References: <1bd79b4a0905190631o234323a5u8073eb41bda04b1b@mail.gmail.com> <391a49da0905190721l1fe2dfc0y4dc0cb3c9892a15a@mail.gmail.com> Message-ID: <1bd79b4a0905190805p6a3dc2e3r461bac740d34813c@mail.gmail.com> Within an apache vhost I'm rewriting like this: RewriteEngine On RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f RewriteRule ^/(.*)$ http://127.0.0.1:5000/$1 [P,QSA,L] I haven't gotten to deployment yet, so I'm not sure if this is what I'm actually going to be doing so suggestions are welcome. Ideally though (since I'll have multiple camping apps) I'd like to have apache forward to many mongrel servers that will be serving up the apps. Dave On Tue, May 19, 2009 at 10:21 AM, Magnus Holm wrote: > Camping uses the Host-header to figure out where the app is located, and > Apache *should* carry forward the header to the Mongrel. How have you set > this up? > If you're using Camping 1.9 or running this through Rack, you could always > create a middleware which changes the Host-header: > class Thing > ??def initialize(app, options = {}) > ?? ?@app = app > ??end > > ??def call(env) > ?? ?@app.call(env.merge({ 'HTTP_HOST' => 'my_vhost.net' })) > ??end > end > app = Thing.new(app) > ------- > I also believe Apache is able to modify HTTP-headers. > > //Magnus Holm > > > On Tue, May 19, 2009 at 15:31, David Susco wrote: >> >> Not sure if this list is still active but I haven't found another yet, >> here's my setup and question. >> >> * I'm running a camping app using a mongrel server listening at >> 127.0.0.1:X. >> * I have a virtual host setup in Apache that is rewriting >> my_vhost.net/my_app/ to 127.0.0.1:X. >> * In one of my controllers I'm trying to redirect to another >> controller like this: redirect Index >> * Instead of being directed to my_vhost.net/my_app/ though the user is >> directed to 127.0.0.1:X. >> >> What's the best/cleanest way to get around this and have the >> controller redirect to my_vhost.net/my_app/? >> >> -- >> Dave >> _______________________________________________ >> Camping-list mailing list >> Camping-list at rubyforge.org >> http://rubyforge.org/mailman/listinfo/camping-list > > > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list > -- Dave From dsusco at gmail.com Wed May 20 13:43:25 2009 From: dsusco at gmail.com (David Susco) Date: Wed, 20 May 2009 13:43:25 -0400 Subject: using ActiveRecord::Validations::ClassMethods Message-ID: <1bd79b4a0905201043y1dfbc99bkf131e76262d5fbc3@mail.gmail.com> Can ActiveRecord::Validations::ClassMethods be used to provide feedback to the user? I noticed the tepee example uses "validates_uniqueness_of ". If the title isn't unique however nothing is written and the user is never notified. Does anyone have an example or two of how I could go about informing the user that the title they entered was not unique and they need to enter another? -- Dave From dsusco at gmail.com Wed May 20 13:53:19 2009 From: dsusco at gmail.com (David Susco) Date: Wed, 20 May 2009 13:53:19 -0400 Subject: using redirect with a mongrel server behind apache In-Reply-To: <1bd79b4a0905190805p6a3dc2e3r461bac740d34813c@mail.gmail.com> References: <1bd79b4a0905190631o234323a5u8073eb41bda04b1b@mail.gmail.com> <391a49da0905190721l1fe2dfc0y4dc0cb3c9892a15a@mail.gmail.com> <1bd79b4a0905190805p6a3dc2e3r461bac740d34813c@mail.gmail.com> Message-ID: <1bd79b4a0905201053t14801f4k1dec4c2a21bc078f@mail.gmail.com> I ended up overwriting the redirect method with this: def redirect *a r(302, '', 'Location' => 'my_vhost.net/my_app/' + R(*a).to_s) end Thoughts? Dave On Tue, May 19, 2009 at 11:05 AM, David Susco wrote: > Within an apache vhost I'm rewriting like this: > > ? ? > ? ? ?RewriteEngine On > ? ? ?RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f > ? ? ?RewriteRule ^/(.*)$ http://127.0.0.1:5000/$1 [P,QSA,L] > ? ? > > I haven't gotten to deployment yet, so I'm not sure if this is what > I'm actually going to be doing so suggestions are welcome. > > Ideally though (since I'll have multiple camping apps) I'd like to > have apache forward to many mongrel servers that will be serving up > the apps. > > Dave > > On Tue, May 19, 2009 at 10:21 AM, Magnus Holm wrote: >> Camping uses the Host-header to figure out where the app is located, and >> Apache *should* carry forward the header to the Mongrel. How have you set >> this up? >> If you're using Camping 1.9 or running this through Rack, you could always >> create a middleware which changes the Host-header: >> class Thing >> ??def initialize(app, options = {}) >> ?? ?@app = app >> ??end >> >> ??def call(env) >> ?? ?@app.call(env.merge({ 'HTTP_HOST' => 'my_vhost.net' })) >> ??end >> end >> app = Thing.new(app) >> ------- >> I also believe Apache is able to modify HTTP-headers. >> >> //Magnus Holm >> >> >> On Tue, May 19, 2009 at 15:31, David Susco wrote: >>> >>> Not sure if this list is still active but I haven't found another yet, >>> here's my setup and question. >>> >>> * I'm running a camping app using a mongrel server listening at >>> 127.0.0.1:X. >>> * I have a virtual host setup in Apache that is rewriting >>> my_vhost.net/my_app/ to 127.0.0.1:X. >>> * In one of my controllers I'm trying to redirect to another >>> controller like this: redirect Index >>> * Instead of being directed to my_vhost.net/my_app/ though the user is >>> directed to 127.0.0.1:X. >>> >>> What's the best/cleanest way to get around this and have the >>> controller redirect to my_vhost.net/my_app/? >>> >>> -- >>> Dave >>> _______________________________________________ >>> Camping-list mailing list >>> Camping-list at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/camping-list >> >> >> _______________________________________________ >> Camping-list mailing list >> Camping-list at rubyforge.org >> http://rubyforge.org/mailman/listinfo/camping-list >> > > > > -- > Dave > -- Dave From judofyr at gmail.com Wed May 20 16:03:04 2009 From: judofyr at gmail.com (Magnus Holm) Date: Wed, 20 May 2009 22:03:04 +0200 Subject: using ActiveRecord::Validations::ClassMethods In-Reply-To: <1bd79b4a0905201043y1dfbc99bkf131e76262d5fbc3@mail.gmail.com> References: <1bd79b4a0905201043y1dfbc99bkf131e76262d5fbc3@mail.gmail.com> Message-ID: <391a49da0905201303l17077137n18ee1144dfe811da@mail.gmail.com> I'm a little rusty on AR at the moment, but I think it looks something like this: In the controller: if @user.valid? # everything is fine else # ops! @user.errors contains the errors end //Magnus Holm On Wed, May 20, 2009 at 19:43, David Susco wrote: > Can ActiveRecord::Validations::ClassMethods be used to provide > feedback to the user? I noticed the tepee example uses > "validates_uniqueness_of ". If the title isn't unique however nothing > is written and the user is never notified. > > Does anyone have an example or two of how I could go about informing > the user that the title they entered was not unique and they need to > enter another? > > -- > Dave > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From judofyr at gmail.com Wed May 20 16:20:46 2009 From: judofyr at gmail.com (Magnus Holm) Date: Wed, 20 May 2009 22:20:46 +0200 Subject: using redirect with a mongrel server behind apache In-Reply-To: <1bd79b4a0905201053t14801f4k1dec4c2a21bc078f@mail.gmail.com> References: <1bd79b4a0905190631o234323a5u8073eb41bda04b1b@mail.gmail.com> <391a49da0905190721l1fe2dfc0y4dc0cb3c9892a15a@mail.gmail.com> <1bd79b4a0905190805p6a3dc2e3r461bac740d34813c@mail.gmail.com> <1bd79b4a0905201053t14801f4k1dec4c2a21bc078f@mail.gmail.com> Message-ID: <391a49da0905201320p435072a9nc145be1f7d30f527@mail.gmail.com> It works, but it's a little weird Camping can't detect it itself. Anyway, the most important thing is that it works :-) //Magnus Holm On Wed, May 20, 2009 at 19:53, David Susco wrote: > I ended up overwriting the redirect method with this: > > def redirect *a > r(302, '', 'Location' => 'my_vhost.net/my_app/' + R(*a).to_s) > end > > Thoughts? > > Dave > > On Tue, May 19, 2009 at 11:05 AM, David Susco wrote: > > Within an apache vhost I'm rewriting like this: > > > > > > RewriteEngine On > > RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f > > RewriteRule ^/(.*)$ http://127.0.0.1:5000/$1 [P,QSA,L] > > > > > > I haven't gotten to deployment yet, so I'm not sure if this is what > > I'm actually going to be doing so suggestions are welcome. > > > > Ideally though (since I'll have multiple camping apps) I'd like to > > have apache forward to many mongrel servers that will be serving up > > the apps. > > > > Dave > > > > On Tue, May 19, 2009 at 10:21 AM, Magnus Holm wrote: > >> Camping uses the Host-header to figure out where the app is located, and > >> Apache *should* carry forward the header to the Mongrel. How have you > set > >> this up? > >> If you're using Camping 1.9 or running this through Rack, you could > always > >> create a middleware which changes the Host-header: > >> class Thing > >> def initialize(app, options = {}) > >> @app = app > >> end > >> > >> def call(env) > >> @app.call(env.merge({ 'HTTP_HOST' => 'my_vhost.net' })) > >> end > >> end > >> app = Thing.new(app) > >> ------- > >> I also believe Apache is able to modify HTTP-headers. > >> > >> //Magnus Holm > >> > >> > >> On Tue, May 19, 2009 at 15:31, David Susco wrote: > >>> > >>> Not sure if this list is still active but I haven't found another yet, > >>> here's my setup and question. > >>> > >>> * I'm running a camping app using a mongrel server listening at > >>> 127.0.0.1:X. > >>> * I have a virtual host setup in Apache that is rewriting > >>> my_vhost.net/my_app/ to 127.0.0.1:X. > >>> * In one of my controllers I'm trying to redirect to another > >>> controller like this: redirect Index > >>> * Instead of being directed to my_vhost.net/my_app/ though the user is > >>> directed to 127.0.0.1:X. > >>> > >>> What's the best/cleanest way to get around this and have the > >>> controller redirect to my_vhost.net/my_app/? > >>> > >>> -- > >>> Dave > >>> _______________________________________________ > >>> Camping-list mailing list > >>> Camping-list at rubyforge.org > >>> http://rubyforge.org/mailman/listinfo/camping-list > >> > >> > >> _______________________________________________ > >> Camping-list mailing list > >> Camping-list at rubyforge.org > >> http://rubyforge.org/mailman/listinfo/camping-list > >> > > > > > > > > -- > > Dave > > > > > > -- > Dave > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kprojection at gmail.com Wed May 20 16:30:19 2009 From: kprojection at gmail.com (Eric Mill) Date: Wed, 20 May 2009 16:30:19 -0400 Subject: using ActiveRecord::Validations::ClassMethods In-Reply-To: <391a49da0905201303l17077137n18ee1144dfe811da@mail.gmail.com> References: <1bd79b4a0905201043y1dfbc99bkf131e76262d5fbc3@mail.gmail.com> <391a49da0905201303l17077137n18ee1144dfe811da@mail.gmail.com> Message-ID: Yeah, but in practice, you'd call @user.save, which internally calls #valid?, and returns true or false on whether the object was saved or not. If the object wasn't saved, @user.errors is populated with the error messages. -- Eric On Wed, May 20, 2009 at 4:03 PM, Magnus Holm wrote: > I'm a little rusty on AR at the moment, but I think it looks something like > this: > In the controller: > if @user.valid? > ??# everything is fine > else > ??# ops! @user.errors contains the errors > end > //Magnus Holm > > > On Wed, May 20, 2009 at 19:43, David Susco wrote: >> >> Can ActiveRecord::Validations::ClassMethods be used to provide >> feedback to the user? I noticed the tepee example uses >> "validates_uniqueness_of ". If the title isn't unique however nothing >> is written and the user is never notified. >> >> Does anyone have an example or two of how I could go about informing >> the user that the title they entered was not unique and they need to >> enter another? >> >> -- >> Dave >> _______________________________________________ >> Camping-list mailing list >> Camping-list at rubyforge.org >> http://rubyforge.org/mailman/listinfo/camping-list > > > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list > From dsusco at gmail.com Wed May 20 16:42:28 2009 From: dsusco at gmail.com (David Susco) Date: Wed, 20 May 2009 16:42:28 -0400 Subject: using ActiveRecord::Validations::ClassMethods In-Reply-To: References: <1bd79b4a0905201043y1dfbc99bkf131e76262d5fbc3@mail.gmail.com> <391a49da0905201303l17077137n18ee1144dfe811da@mail.gmail.com> Message-ID: <1bd79b4a0905201342r226ac5e1yb5f18c2ecec22887@mail.gmail.com> So, in my crud controllers, should I be using calls to save instead of create and update_attributes? As those just return the object, and not true of false based on my validations. Dave On Wed, May 20, 2009 at 4:30 PM, Eric Mill wrote: > Yeah, but in practice, you'd call @user.save, which internally calls > #valid?, and returns true or false on whether the object was saved or > not. If the object wasn't saved, @user.errors is populated with the > error messages. > > -- Eric > > On Wed, May 20, 2009 at 4:03 PM, Magnus Holm wrote: >> I'm a little rusty on AR at the moment, but I think it looks something like >> this: >> In the controller: >> if @user.valid? >> ??# everything is fine >> else >> ??# ops! @user.errors contains the errors >> end >> //Magnus Holm >> >> >> On Wed, May 20, 2009 at 19:43, David Susco wrote: >>> >>> Can ActiveRecord::Validations::ClassMethods be used to provide >>> feedback to the user? I noticed the tepee example uses >>> "validates_uniqueness_of ". If the title isn't unique however nothing >>> is written and the user is never notified. >>> >>> Does anyone have an example or two of how I could go about informing >>> the user that the title they entered was not unique and they need to >>> enter another? >>> >>> -- >>> Dave >>> _______________________________________________ >>> Camping-list mailing list >>> Camping-list at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/camping-list >> >> >> _______________________________________________ >> Camping-list mailing list >> Camping-list at rubyforge.org >> http://rubyforge.org/mailman/listinfo/camping-list >> > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list > -- Dave From kprojection at gmail.com Wed May 20 17:27:27 2009 From: kprojection at gmail.com (Eric Mill) Date: Wed, 20 May 2009 17:27:27 -0400 Subject: using ActiveRecord::Validations::ClassMethods In-Reply-To: <1bd79b4a0905201342r226ac5e1yb5f18c2ecec22887@mail.gmail.com> References: <1bd79b4a0905201043y1dfbc99bkf131e76262d5fbc3@mail.gmail.com> <391a49da0905201303l17077137n18ee1144dfe811da@mail.gmail.com> <1bd79b4a0905201342r226ac5e1yb5f18c2ecec22887@mail.gmail.com> Message-ID: In my create actions, I customarily do like @user = User.new params[:user if @user.save ... else ... end But update_attributes should also return true or false, I believe. On Wed, May 20, 2009 at 4:42 PM, David Susco wrote: > So, in my crud controllers, should I be using calls to save instead of > create and update_attributes? As those just return the object, and not > true of false based on my validations. > > Dave > > On Wed, May 20, 2009 at 4:30 PM, Eric Mill wrote: >> Yeah, but in practice, you'd call @user.save, which internally calls >> #valid?, and returns true or false on whether the object was saved or >> not. If the object wasn't saved, @user.errors is populated with the >> error messages. >> >> -- Eric >> >> On Wed, May 20, 2009 at 4:03 PM, Magnus Holm wrote: >>> I'm a little rusty on AR at the moment, but I think it looks something like >>> this: >>> In the controller: >>> if @user.valid? >>> ??# everything is fine >>> else >>> ??# ops! @user.errors contains the errors >>> end >>> //Magnus Holm >>> >>> >>> On Wed, May 20, 2009 at 19:43, David Susco wrote: >>>> >>>> Can ActiveRecord::Validations::ClassMethods be used to provide >>>> feedback to the user? I noticed the tepee example uses >>>> "validates_uniqueness_of ". If the title isn't unique however nothing >>>> is written and the user is never notified. >>>> >>>> Does anyone have an example or two of how I could go about informing >>>> the user that the title they entered was not unique and they need to >>>> enter another? >>>> >>>> -- >>>> Dave >>>> _______________________________________________ >>>> Camping-list mailing list >>>> Camping-list at rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/camping-list >>> >>> >>> _______________________________________________ >>> Camping-list mailing list >>> Camping-list at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/camping-list >>> >> _______________________________________________ >> Camping-list mailing list >> Camping-list at rubyforge.org >> http://rubyforge.org/mailman/listinfo/camping-list >> > > > > -- > Dave > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list > From dsusco at gmail.com Thu May 21 09:50:53 2009 From: dsusco at gmail.com (David Susco) Date: Thu, 21 May 2009 09:50:53 -0400 Subject: using ActiveRecord::Validations::ClassMethods In-Reply-To: References: <1bd79b4a0905201043y1dfbc99bkf131e76262d5fbc3@mail.gmail.com> <391a49da0905201303l17077137n18ee1144dfe811da@mail.gmail.com> <1bd79b4a0905201342r226ac5e1yb5f18c2ecec22887@mail.gmail.com> Message-ID: <1bd79b4a0905210650o16ba8ef3uf6095ae6f1a6e555@mail.gmail.com> Thanks, I've gotten it to work. On this part though: @user = User.new params[:user Is the closing bracket missing? Is params something from Rails that allows you to create the user instance variable all in one line instead of doing something like this: @user = User.new( :id => input.id, :name => input.name, ... ) Can I use it in a camping app relatively easily? Dave On Wed, May 20, 2009 at 5:27 PM, Eric Mill wrote: > In my create actions, I customarily do like > > @user = User.new params[:user > if @user.save > ?... > else > ?... > end > > But update_attributes should also return true or false, I believe. > > On Wed, May 20, 2009 at 4:42 PM, David Susco wrote: >> So, in my crud controllers, should I be using calls to save instead of >> create and update_attributes? As those just return the object, and not >> true of false based on my validations. >> >> Dave >> >> On Wed, May 20, 2009 at 4:30 PM, Eric Mill wrote: >>> Yeah, but in practice, you'd call @user.save, which internally calls >>> #valid?, and returns true or false on whether the object was saved or >>> not. If the object wasn't saved, @user.errors is populated with the >>> error messages. >>> >>> -- Eric >>> >>> On Wed, May 20, 2009 at 4:03 PM, Magnus Holm wrote: >>>> I'm a little rusty on AR at the moment, but I think it looks something like >>>> this: >>>> In the controller: >>>> if @user.valid? >>>> ??# everything is fine >>>> else >>>> ??# ops! @user.errors contains the errors >>>> end >>>> //Magnus Holm >>>> >>>> >>>> On Wed, May 20, 2009 at 19:43, David Susco wrote: >>>>> >>>>> Can ActiveRecord::Validations::ClassMethods be used to provide >>>>> feedback to the user? I noticed the tepee example uses >>>>> "validates_uniqueness_of ". If the title isn't unique however nothing >>>>> is written and the user is never notified. >>>>> >>>>> Does anyone have an example or two of how I could go about informing >>>>> the user that the title they entered was not unique and they need to >>>>> enter another? >>>>> >>>>> -- >>>>> Dave >>>>> _______________________________________________ >>>>> Camping-list mailing list >>>>> Camping-list at rubyforge.org >>>>> http://rubyforge.org/mailman/listinfo/camping-list >>>> >>>> >>>> _______________________________________________ >>>> Camping-list mailing list >>>> Camping-list at rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/camping-list >>>> >>> _______________________________________________ >>> Camping-list mailing list >>> Camping-list at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/camping-list >>> >> >> >> >> -- >> Dave >> _______________________________________________ >> Camping-list mailing list >> Camping-list at rubyforge.org >> http://rubyforge.org/mailman/listinfo/camping-list >> > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list > -- Dave From kprojection at gmail.com Thu May 21 10:14:19 2009 From: kprojection at gmail.com (Eric Mill) Date: Thu, 21 May 2009 10:14:19 -0400 Subject: using ActiveRecord::Validations::ClassMethods In-Reply-To: <1bd79b4a0905210650o16ba8ef3uf6095ae6f1a6e555@mail.gmail.com> References: <1bd79b4a0905201043y1dfbc99bkf131e76262d5fbc3@mail.gmail.com> <391a49da0905201303l17077137n18ee1144dfe811da@mail.gmail.com> <1bd79b4a0905201342r226ac5e1yb5f18c2ecec22887@mail.gmail.com> <1bd79b4a0905210650o16ba8ef3uf6095ae6f1a6e555@mail.gmail.com> Message-ID: Hah, yeah, the bracket is missing. And in Camping, the equivalent of Rails' "params" is "@input". -- Eric On Thu, May 21, 2009 at 9:50 AM, David Susco wrote: > Thanks, I've gotten it to work. > > On this part though: @user = User.new params[:user > > Is the closing bracket missing? Is params something from Rails that > allows you to create the user instance variable all in one line > instead of doing something like this: > > @user = User.new( > ?:id => input.id, > ?:name => input.name, > ?... > ) > > Can I use it in a camping app relatively easily? > > Dave > > On Wed, May 20, 2009 at 5:27 PM, Eric Mill wrote: >> In my create actions, I customarily do like >> >> @user = User.new params[:user >> if @user.save >> ?... >> else >> ?... >> end >> >> But update_attributes should also return true or false, I believe. >> >> On Wed, May 20, 2009 at 4:42 PM, David Susco wrote: >>> So, in my crud controllers, should I be using calls to save instead of >>> create and update_attributes? As those just return the object, and not >>> true of false based on my validations. >>> >>> Dave >>> >>> On Wed, May 20, 2009 at 4:30 PM, Eric Mill wrote: >>>> Yeah, but in practice, you'd call @user.save, which internally calls >>>> #valid?, and returns true or false on whether the object was saved or >>>> not. If the object wasn't saved, @user.errors is populated with the >>>> error messages. >>>> >>>> -- Eric >>>> >>>> On Wed, May 20, 2009 at 4:03 PM, Magnus Holm wrote: >>>>> I'm a little rusty on AR at the moment, but I think it looks something like >>>>> this: >>>>> In the controller: >>>>> if @user.valid? >>>>> ??# everything is fine >>>>> else >>>>> ??# ops! @user.errors contains the errors >>>>> end >>>>> //Magnus Holm >>>>> >>>>> >>>>> On Wed, May 20, 2009 at 19:43, David Susco wrote: >>>>>> >>>>>> Can ActiveRecord::Validations::ClassMethods be used to provide >>>>>> feedback to the user? I noticed the tepee example uses >>>>>> "validates_uniqueness_of ". If the title isn't unique however nothing >>>>>> is written and the user is never notified. >>>>>> >>>>>> Does anyone have an example or two of how I could go about informing >>>>>> the user that the title they entered was not unique and they need to >>>>>> enter another? >>>>>> >>>>>> -- >>>>>> Dave >>>>>> _______________________________________________ >>>>>> Camping-list mailing list >>>>>> Camping-list at rubyforge.org >>>>>> http://rubyforge.org/mailman/listinfo/camping-list >>>>> >>>>> >>>>> _______________________________________________ >>>>> Camping-list mailing list >>>>> Camping-list at rubyforge.org >>>>> http://rubyforge.org/mailman/listinfo/camping-list >>>>> >>>> _______________________________________________ >>>> Camping-list mailing list >>>> Camping-list at rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/camping-list >>>> >>> >>> >>> >>> -- >>> Dave >>> _______________________________________________ >>> Camping-list mailing list >>> Camping-list at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/camping-list >>> >> _______________________________________________ >> Camping-list mailing list >> Camping-list at rubyforge.org >> http://rubyforge.org/mailman/listinfo/camping-list >> > > > > -- > Dave > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list > From judofyr at gmail.com Thu May 21 10:22:01 2009 From: judofyr at gmail.com (Magnus Holm) Date: Thu, 21 May 2009 16:22:01 +0200 Subject: using ActiveRecord::Validations::ClassMethods In-Reply-To: <1bd79b4a0905210650o16ba8ef3uf6095ae6f1a6e555@mail.gmail.com> References: <1bd79b4a0905201043y1dfbc99bkf131e76262d5fbc3@mail.gmail.com> <391a49da0905201303l17077137n18ee1144dfe811da@mail.gmail.com> <1bd79b4a0905201342r226ac5e1yb5f18c2ecec22887@mail.gmail.com> <1bd79b4a0905210650o16ba8ef3uf6095ae6f1a6e555@mail.gmail.com> Message-ID: <391a49da0905210722g39ad58a3l5136940e1d63c60f@mail.gmail.com> params is simply Rails' version of @input. If you name your keys "user[id]" and "user[name]" in the HTML, then @input.user should contain a Hash like { 'id' => ..., 'name' => ... } (maybe the keys are Symbols; I don't remember at the moment) //Magnus Holm On Thu, May 21, 2009 at 15:50, David Susco wrote: > Thanks, I've gotten it to work. > > On this part though: @user = User.new params[:user > > Is the closing bracket missing? Is params something from Rails that > allows you to create the user instance variable all in one line > instead of doing something like this: > > @user = User.new( > :id => input.id, > :name => input.name, > ... > ) > > Can I use it in a camping app relatively easily? > > Dave > > On Wed, May 20, 2009 at 5:27 PM, Eric Mill wrote: > > In my create actions, I customarily do like > > > > @user = User.new params[:user > > if @user.save > > ... > > else > > ... > > end > > > > But update_attributes should also return true or false, I believe. > > > > On Wed, May 20, 2009 at 4:42 PM, David Susco wrote: > >> So, in my crud controllers, should I be using calls to save instead of > >> create and update_attributes? As those just return the object, and not > >> true of false based on my validations. > >> > >> Dave > >> > >> On Wed, May 20, 2009 at 4:30 PM, Eric Mill > wrote: > >>> Yeah, but in practice, you'd call @user.save, which internally calls > >>> #valid?, and returns true or false on whether the object was saved or > >>> not. If the object wasn't saved, @user.errors is populated with the > >>> error messages. > >>> > >>> -- Eric > >>> > >>> On Wed, May 20, 2009 at 4:03 PM, Magnus Holm > wrote: > >>>> I'm a little rusty on AR at the moment, but I think it looks something > like > >>>> this: > >>>> In the controller: > >>>> if @user.valid? > >>>> # everything is fine > >>>> else > >>>> # ops! @user.errors contains the errors > >>>> end > >>>> //Magnus Holm > >>>> > >>>> > >>>> On Wed, May 20, 2009 at 19:43, David Susco wrote: > >>>>> > >>>>> Can ActiveRecord::Validations::ClassMethods be used to provide > >>>>> feedback to the user? I noticed the tepee example uses > >>>>> "validates_uniqueness_of ". If the title isn't unique however nothing > >>>>> is written and the user is never notified. > >>>>> > >>>>> Does anyone have an example or two of how I could go about informing > >>>>> the user that the title they entered was not unique and they need to > >>>>> enter another? > >>>>> > >>>>> -- > >>>>> Dave > >>>>> _______________________________________________ > >>>>> Camping-list mailing list > >>>>> Camping-list at rubyforge.org > >>>>> http://rubyforge.org/mailman/listinfo/camping-list > >>>> > >>>> > >>>> _______________________________________________ > >>>> Camping-list mailing list > >>>> Camping-list at rubyforge.org > >>>> http://rubyforge.org/mailman/listinfo/camping-list > >>>> > >>> _______________________________________________ > >>> Camping-list mailing list > >>> Camping-list at rubyforge.org > >>> http://rubyforge.org/mailman/listinfo/camping-list > >>> > >> > >> > >> > >> -- > >> Dave > >> _______________________________________________ > >> Camping-list mailing list > >> Camping-list at rubyforge.org > >> http://rubyforge.org/mailman/listinfo/camping-list > >> > > _______________________________________________ > > Camping-list mailing list > > Camping-list at rubyforge.org > > http://rubyforge.org/mailman/listinfo/camping-list > > > > > > -- > Dave > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dsusco at gmail.com Fri May 22 09:09:48 2009 From: dsusco at gmail.com (David Susco) Date: Fri, 22 May 2009 09:09:48 -0400 Subject: using ActiveRecord::Validations::ClassMethods In-Reply-To: <391a49da0905210722g39ad58a3l5136940e1d63c60f@mail.gmail.com> References: <1bd79b4a0905201043y1dfbc99bkf131e76262d5fbc3@mail.gmail.com> <391a49da0905201303l17077137n18ee1144dfe811da@mail.gmail.com> <1bd79b4a0905201342r226ac5e1yb5f18c2ecec22887@mail.gmail.com> <1bd79b4a0905210650o16ba8ef3uf6095ae6f1a6e555@mail.gmail.com> <391a49da0905210722g39ad58a3l5136940e1d63c60f@mail.gmail.com> Message-ID: <1bd79b4a0905220609y1af36581la581ea7691177250@mail.gmail.com> Thanks guys, That helped get rid of a lot of code. Dave On Thu, May 21, 2009 at 10:22 AM, Magnus Holm wrote: > params is simply Rails' version of @input. > If you name your keys "user[id]" and "user[name]" in the HTML, then > @input.user should contain a Hash like { 'id' => ..., 'name' => ... } (maybe > the keys are Symbols; I don't remember at the moment) > //Magnus Holm > > > On Thu, May 21, 2009 at 15:50, David Susco wrote: >> >> Thanks, I've gotten it to work. >> >> On this part though: @user = User.new params[:user >> >> Is the closing bracket missing? Is params something from Rails that >> allows you to create the user instance variable all in one line >> instead of doing something like this: >> >> @user = User.new( >> ?:id => input.id, >> ?:name => input.name, >> ?... >> ) >> >> Can I use it in a camping app relatively easily? >> >> Dave >> >> On Wed, May 20, 2009 at 5:27 PM, Eric Mill wrote: >> > In my create actions, I customarily do like >> > >> > @user = User.new params[:user >> > if @user.save >> > ?... >> > else >> > ?... >> > end >> > >> > But update_attributes should also return true or false, I believe. >> > >> > On Wed, May 20, 2009 at 4:42 PM, David Susco wrote: >> >> So, in my crud controllers, should I be using calls to save instead of >> >> create and update_attributes? As those just return the object, and not >> >> true of false based on my validations. >> >> >> >> Dave >> >> >> >> On Wed, May 20, 2009 at 4:30 PM, Eric Mill >> >> wrote: >> >>> Yeah, but in practice, you'd call @user.save, which internally calls >> >>> #valid?, and returns true or false on whether the object was saved or >> >>> not. If the object wasn't saved, @user.errors is populated with the >> >>> error messages. >> >>> >> >>> -- Eric >> >>> >> >>> On Wed, May 20, 2009 at 4:03 PM, Magnus Holm >> >>> wrote: >> >>>> I'm a little rusty on AR at the moment, but I think it looks >> >>>> something like >> >>>> this: >> >>>> In the controller: >> >>>> if @user.valid? >> >>>> ??# everything is fine >> >>>> else >> >>>> ??# ops! @user.errors contains the errors >> >>>> end >> >>>> //Magnus Holm >> >>>> >> >>>> >> >>>> On Wed, May 20, 2009 at 19:43, David Susco wrote: >> >>>>> >> >>>>> Can ActiveRecord::Validations::ClassMethods be used to provide >> >>>>> feedback to the user? I noticed the tepee example uses >> >>>>> "validates_uniqueness_of ". If the title isn't unique however >> >>>>> nothing >> >>>>> is written and the user is never notified. >> >>>>> >> >>>>> Does anyone have an example or two of how I could go about informing >> >>>>> the user that the title they entered was not unique and they need to >> >>>>> enter another? >> >>>>> >> >>>>> -- >> >>>>> Dave >> >>>>> _______________________________________________ >> >>>>> Camping-list mailing list >> >>>>> Camping-list at rubyforge.org >> >>>>> http://rubyforge.org/mailman/listinfo/camping-list >> >>>> >> >>>> >> >>>> _______________________________________________ >> >>>> Camping-list mailing list >> >>>> Camping-list at rubyforge.org >> >>>> http://rubyforge.org/mailman/listinfo/camping-list >> >>>> >> >>> _______________________________________________ >> >>> Camping-list mailing list >> >>> Camping-list at rubyforge.org >> >>> http://rubyforge.org/mailman/listinfo/camping-list >> >>> >> >> >> >> >> >> >> >> -- >> >> Dave >> >> _______________________________________________ >> >> Camping-list mailing list >> >> Camping-list at rubyforge.org >> >> http://rubyforge.org/mailman/listinfo/camping-list >> >> >> > _______________________________________________ >> > Camping-list mailing list >> > Camping-list at rubyforge.org >> > http://rubyforge.org/mailman/listinfo/camping-list >> > >> >> >> >> -- >> Dave >> _______________________________________________ >> Camping-list mailing list >> Camping-list at rubyforge.org >> http://rubyforge.org/mailman/listinfo/camping-list > > > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list > -- Dave From his2000x at gmail.com Fri May 22 10:02:31 2009 From: his2000x at gmail.com (in-seok hwang) Date: Fri, 22 May 2009 23:02:31 +0900 Subject: hi all! i don't know that javascript into the ruby variable Message-ID: hi all! sorry! i'm not speak english well. but, i want to learning. this is my code. 553 text <<-JAVASCRIPT > 554 > 577 JAVASCRIPT > I would like to put in javascript's variable(name) to red point. but , i can't remember Programming syntax. plz give me hint. thank you for reading my artcle. have a nice day. -------------- next part -------------- An HTML attachment was scrubbed... URL: From kprojection at gmail.com Fri May 22 11:04:15 2009 From: kprojection at gmail.com (Eric Mill) Date: Fri, 22 May 2009 11:04:15 -0400 Subject: using ActiveRecord::Validations::ClassMethods In-Reply-To: <1bd79b4a0905220609y1af36581la581ea7691177250@mail.gmail.com> References: <1bd79b4a0905201043y1dfbc99bkf131e76262d5fbc3@mail.gmail.com> <391a49da0905201303l17077137n18ee1144dfe811da@mail.gmail.com> <1bd79b4a0905201342r226ac5e1yb5f18c2ecec22887@mail.gmail.com> <1bd79b4a0905210650o16ba8ef3uf6095ae6f1a6e555@mail.gmail.com> <391a49da0905210722g39ad58a3l5136940e1d63c60f@mail.gmail.com> <1bd79b4a0905220609y1af36581la581ea7691177250@mail.gmail.com> Message-ID: Awesome! The only thing more fun than writing code is deleting code. On Fri, May 22, 2009 at 9:09 AM, David Susco wrote: > Thanks guys, > > That helped get rid of a lot of code. > > Dave > > On Thu, May 21, 2009 at 10:22 AM, Magnus Holm wrote: >> params is simply Rails' version of @input. >> If you name your keys "user[id]" and "user[name]" in the HTML, then >> @input.user should contain a Hash like { 'id' => ..., 'name' => ... } (maybe >> the keys are Symbols; I don't remember at the moment) >> //Magnus Holm >> >> >> On Thu, May 21, 2009 at 15:50, David Susco wrote: >>> >>> Thanks, I've gotten it to work. >>> >>> On this part though: @user = User.new params[:user >>> >>> Is the closing bracket missing? Is params something from Rails that >>> allows you to create the user instance variable all in one line >>> instead of doing something like this: >>> >>> @user = User.new( >>> ?:id => input.id, >>> ?:name => input.name, >>> ?... >>> ) >>> >>> Can I use it in a camping app relatively easily? >>> >>> Dave >>> >>> On Wed, May 20, 2009 at 5:27 PM, Eric Mill wrote: >>> > In my create actions, I customarily do like >>> > >>> > @user = User.new params[:user >>> > if @user.save >>> > ?... >>> > else >>> > ?... >>> > end >>> > >>> > But update_attributes should also return true or false, I believe. >>> > >>> > On Wed, May 20, 2009 at 4:42 PM, David Susco wrote: >>> >> So, in my crud controllers, should I be using calls to save instead of >>> >> create and update_attributes? As those just return the object, and not >>> >> true of false based on my validations. >>> >> >>> >> Dave >>> >> >>> >> On Wed, May 20, 2009 at 4:30 PM, Eric Mill >>> >> wrote: >>> >>> Yeah, but in practice, you'd call @user.save, which internally calls >>> >>> #valid?, and returns true or false on whether the object was saved or >>> >>> not. If the object wasn't saved, @user.errors is populated with the >>> >>> error messages. >>> >>> >>> >>> -- Eric >>> >>> >>> >>> On Wed, May 20, 2009 at 4:03 PM, Magnus Holm >>> >>> wrote: >>> >>>> I'm a little rusty on AR at the moment, but I think it looks >>> >>>> something like >>> >>>> this: >>> >>>> In the controller: >>> >>>> if @user.valid? >>> >>>> ??# everything is fine >>> >>>> else >>> >>>> ??# ops! @user.errors contains the errors >>> >>>> end >>> >>>> //Magnus Holm >>> >>>> >>> >>>> >>> >>>> On Wed, May 20, 2009 at 19:43, David Susco wrote: >>> >>>>> >>> >>>>> Can ActiveRecord::Validations::ClassMethods be used to provide >>> >>>>> feedback to the user? I noticed the tepee example uses >>> >>>>> "validates_uniqueness_of ". If the title isn't unique however >>> >>>>> nothing >>> >>>>> is written and the user is never notified. >>> >>>>> >>> >>>>> Does anyone have an example or two of how I could go about informing >>> >>>>> the user that the title they entered was not unique and they need to >>> >>>>> enter another? >>> >>>>> >>> >>>>> -- >>> >>>>> Dave >>> >>>>> _______________________________________________ >>> >>>>> Camping-list mailing list >>> >>>>> Camping-list at rubyforge.org >>> >>>>> http://rubyforge.org/mailman/listinfo/camping-list >>> >>>> >>> >>>> >>> >>>> _______________________________________________ >>> >>>> Camping-list mailing list >>> >>>> Camping-list at rubyforge.org >>> >>>> http://rubyforge.org/mailman/listinfo/camping-list >>> >>>> >>> >>> _______________________________________________ >>> >>> Camping-list mailing list >>> >>> Camping-list at rubyforge.org >>> >>> http://rubyforge.org/mailman/listinfo/camping-list >>> >>> >>> >> >>> >> >>> >> >>> >> -- >>> >> Dave >>> >> _______________________________________________ >>> >> Camping-list mailing list >>> >> Camping-list at rubyforge.org >>> >> http://rubyforge.org/mailman/listinfo/camping-list >>> >> >>> > _______________________________________________ >>> > Camping-list mailing list >>> > Camping-list at rubyforge.org >>> > http://rubyforge.org/mailman/listinfo/camping-list >>> > >>> >>> >>> >>> -- >>> Dave >>> _______________________________________________ >>> Camping-list mailing list >>> Camping-list at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/camping-list >> >> >> _______________________________________________ >> Camping-list mailing list >> Camping-list at rubyforge.org >> http://rubyforge.org/mailman/listinfo/camping-list >> > > > > -- > Dave > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list > From kprojection at gmail.com Fri May 22 11:05:49 2009 From: kprojection at gmail.com (Eric Mill) Date: Fri, 22 May 2009 11:05:49 -0400 Subject: hi all! i don't know that javascript into the ruby variable In-Reply-To: References: Message-ID: That actually is not going to be possible, the way you're doing it. ERB can't evaluate the JavaScript like that. What you might want to do is to write the @people hash out onto the page somewhere else first, as a JavaScript hash, and then have your function look up [name] in the JS hash. -- Eric On Fri, May 22, 2009 at 10:02 AM, in-seok hwang wrote: > hi all! > > sorry! i'm not speak english well. > but, i want to learning. > > this is my code. > >> 553 text <<-JAVASCRIPT >> 554 >> 577 JAVASCRIPT > > I would like to put in javascript's variable(name) to red point. > > but , i can't remember Programming syntax. > > plz give me hint. > > thank you for reading my artcle. > > have a nice day. > > > > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list >