Re: [Rails] Unable to connect my ruby on rails APP to a SVN repository
Yes I tried , but I get the same error. I´ve tried to send the output to a file and it works. I supose the problem is the console or I don´t know. The problem is that it's double effort and it's not efficient so I'll keep trying. El viernes, 28 de junio de 2019, 14:58:04 (UTC+2), Ariel Juodziukynas escribió: > > Have you tried the --verbose option when you run the command? it should > give you some information of all the steps that the command executes. > > El vie., 28 jun. 2019 a las 7:15, Harold Alcalde Solarte (< > haroldalca...@gmail.com >) escribió: > >> Blank space is an error when copying. >> The command works I use the same command with another repository smaller >> than this, I was thinking if it's something of the response time or the >> timeout, but I can not find anything. >> >> El jueves, 27 de junio de 2019, 15:39:41 (UTC+2), Ariel Juodziukynas >> escribió: >>> >>> You have no blank space between USER and "--password". Also add the >>> option "--verbose" to the comend to see more info of the request. Are you >>> sure the command works? I mean, I don't see how it's related to ruby nor >>> rubyonrails. >>> >>> El jue., 27 jun. 2019 a las 10:12, Harold Alcalde Solarte (< >>> haroldalca...@gmail.com>) escribió: >>> >>>> Hi all, >>>> >>>> I am trying to create in my APP a tree of directories from the data of >>>> the SVN repository. My app is on Windows and the repository I'm trying to >>>> access on another Linux server. >>>> I'm using the command to get all the files and folders: >>>> >>>> 'svn list -R http://172.xx.xx.xx/repos/Ttest/ --trust-server-cert >>>> --non-interactive --username USER--password PASSWORD' >>>> >>>> When I execute the command it doesnt do anything and once the execution >>>> is cut, the following error is shown: >>>> >>>> >>>> svn: E200015: Se atrapó una señal >>>> svn: E200015: Se atrapó una señal >>>> svn: E200015: Se atrapó una señal >>>> svn: E170013: Unable to connect to a repository at URL ' >>>> http://172.xx.xx.xx/repos/Ttest/test1.txt' >>>> svn: E200015: Se atrapó una señal >>>> svn: E200015: Se atrapó una señal >>>> >>>> >>>> I have searched for those errors but I can not find a solution. >>>> >>>> Any suggestions? >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Ruby on Rails: Talk" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to rubyonra...@googlegroups.com. >>>> To post to this group, send email to rubyonra...@googlegroups.com. >>>> To view this discussion on the web visit >>>> https://groups.google.com/d/msgid/rubyonrails-talk/c94a665a-ae09-4cea-a452-3cbc5a9eaf80%40googlegroups.com >>>> >>>> <https://groups.google.com/d/msgid/rubyonrails-talk/c94a665a-ae09-4cea-a452-3cbc5a9eaf80%40googlegroups.com?utm_medium=email&utm_source=footer> >>>> . >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Talk" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to rubyonra...@googlegroups.com . >> To post to this group, send email to rubyonra...@googlegroups.com >> . >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/rubyonrails-talk/7894c38e-f837-4659-8fac-85eaf9b21581%40googlegroups.com >> >> <https://groups.google.com/d/msgid/rubyonrails-talk/7894c38e-f837-4659-8fac-85eaf9b21581%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/7f4b3794-ce0b-4888-a6d4-422b9f9ddcde%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [Rails] Unable to connect my ruby on rails APP to a SVN repository
Blank space is an error when copying. The command works I use the same command with another repository smaller than this, I was thinking if it's something of the response time or the timeout, but I can not find anything. El jueves, 27 de junio de 2019, 15:39:41 (UTC+2), Ariel Juodziukynas escribió: > > You have no blank space between USER and "--password". Also add the option > "--verbose" to the comend to see more info of the request. Are you sure the > command works? I mean, I don't see how it's related to ruby nor rubyonrails. > > El jue., 27 jun. 2019 a las 10:12, Harold Alcalde Solarte (< > haroldalca...@gmail.com >) escribió: > >> Hi all, >> >> I am trying to create in my APP a tree of directories from the data of >> the SVN repository. My app is on Windows and the repository I'm trying to >> access on another Linux server. >> I'm using the command to get all the files and folders: >> >> 'svn list -R http://172.xx.xx.xx/repos/Ttest/ --trust-server-cert >> --non-interactive >> --username USER--password PASSWORD' >> >> When I execute the command it doesnt do anything and once the execution >> is cut, the following error is shown: >> >> >> svn: E200015: Se atrapó una señal >> svn: E200015: Se atrapó una señal >> svn: E200015: Se atrapó una señal >> svn: E170013: Unable to connect to a repository at URL ' >> http://172.xx.xx.xx/repos/Ttest/test1.txt' >> svn: E200015: Se atrapó una señal >> svn: E200015: Se atrapó una señal >> >> >> I have searched for those errors but I can not find a solution. >> >> Any suggestions? >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Talk" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to rubyonra...@googlegroups.com . >> To post to this group, send email to rubyonra...@googlegroups.com >> . >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/rubyonrails-talk/c94a665a-ae09-4cea-a452-3cbc5a9eaf80%40googlegroups.com >> >> <https://groups.google.com/d/msgid/rubyonrails-talk/c94a665a-ae09-4cea-a452-3cbc5a9eaf80%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/7894c38e-f837-4659-8fac-85eaf9b21581%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[Rails] Unable to connect my ruby on rails APP to a SVN repository
Hi all, I am trying to create in my APP a tree of directories from the data of the SVN repository. My app is on Windows and the repository I'm trying to access on another Linux server. I'm using the command to get all the files and folders: 'svn list -R http://172.xx.xx.xx/repos/Ttest/ --trust-server-cert --non-interactive --username USER--password PASSWORD' When I execute the command it doesnt do anything and once the execution is cut, the following error is shown: svn: E200015: Se atrapó una señal svn: E200015: Se atrapó una señal svn: E200015: Se atrapó una señal svn: E170013: Unable to connect to a repository at URL ' http://172.xx.xx.xx/repos/Ttest/test1.txt' svn: E200015: Se atrapó una señal svn: E200015: Se atrapó una señal I have searched for those errors but I can not find a solution. Any suggestions? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/c94a665a-ae09-4cea-a452-3cbc5a9eaf80%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [Rails] Re: My program does not work after adding helpler
On Monday, November 2, 2015 at 10:33:32 AM UTC-6, James Harold wrote: > > > > On Monday, November 2, 2015 at 10:18:01 AM UTC-6, Colin Law wrote: >> >> On 2 November 2015 at 16:01, James Harold wrote: >> > >> > BTW, the error is listed here: >> > >> > 1) Failure: >> > StaticPagesControllerTest#test_should_get_about >> > >> [C:/Sites/sample_app/test/controllers/static_pages_controller_test.rb:19]: >> > expected but was >> > . >> >> The test producing that is >> test "should get about" do >> get :about >> assert_response :success >> assert_select "title", "About | Ruby on Rails Tutorial Sample App" >> end >> >> What do you think that error is trying to tell you? >> >> Colin >> > > > It tells the program to perform the GET function for the HTML page, keep > running the page when success is returned upon matching, and then select > the page desired by the programmer and display it on the screen. I have > also worked on the program, and have narrowed it down to two failure > errors. They are listed here: > > 1) Failure: > StaticPagesControllerTest#test_should_get_about > [C:/Sites/sample_app/test/controllers/static_pages_controller_test.rb:19]: > expected but was > . > Expected 0 to be >= 1. > > > 2) Failure: > StaticPagesControllerTest#test_should_get_help > [C:/Sites/sample_app/test/controllers/static_pages_controller_test.rb:13]: > expected but was > . > Expected 0 to be >= 1. > > What should I do next? How do I fix this? > Also, here is the new test file: class StaticPagesControllerTest < ActionController::TestCase test "should get home" do get :home assert_response :success assert_select "title", "Ruby on Rails Tutorial Sample App." end test "should get help" do get :help assert_response :success assert_select "title", "Help | Ruby on Rails Tutorial Sample App." end test "should get about" do get :about assert_response :success assert_select "title", "About | Ruby on Rails Tutorial Sample App." end test "should get contact" do get :contact assert_response :success assert_select "title", "Contact | Ruby on Rails Tutorial Sample App." end end -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/fc8debe8-96e8-4004-acbb-9f6c0ae4%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [Rails] Re: My program does not work after adding helpler
On Monday, November 2, 2015 at 10:18:01 AM UTC-6, Colin Law wrote: > > On 2 November 2015 at 16:01, James Harold > wrote: > > > > BTW, the error is listed here: > > > > 1) Failure: > > StaticPagesControllerTest#test_should_get_about > > > [C:/Sites/sample_app/test/controllers/static_pages_controller_test.rb:19]: > > expected but was > > . > > The test producing that is > test "should get about" do > get :about > assert_response :success > assert_select "title", "About | Ruby on Rails Tutorial Sample App" > end > > What do you think that error is trying to tell you? > > Colin > It tells the program to perform the GET function for the HTML page, keep running the page when success is returned upon matching, and then select the page desired by the programmer and display it on the screen. I have also worked on the program, and have narrowed it down to two failure errors. They are listed here: 1) Failure: StaticPagesControllerTest#test_should_get_about [C:/Sites/sample_app/test/controllers/static_pages_controller_test.rb:19]: expected but was . Expected 0 to be >= 1. 2) Failure: StaticPagesControllerTest#test_should_get_help [C:/Sites/sample_app/test/controllers/static_pages_controller_test.rb:13]: expected but was . Expected 0 to be >= 1. What should I do next? How do I fix this? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/35ee8201-0407-4574-8d55-f0bff6b1d566%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[Rails] Re: My program does not work after adding helpler
On Sunday, November 1, 2015 at 8:15:53 PM UTC-6, James Harold wrote: > > I have just gotten to Chapter Four of Michael Hartl's Ruby on Rails > Tutorial, and I can't seem to get the program to work after adding a helper > to the program. Here is the code from the files. > > static_pages_controller_test.rb > require 'test_helper' > > class StaticPagesControllerTest < ActionController::TestCase > test "should get home" do > get :home > assert_response :success > assert_select "title", "Ruby on Rails Tutorial Sample App" > end > > test "should get help" do > get :help > assert_response :success > assert_select "title", "Help | Ruby on Rails Tutorial Sample App" > end > > test "should get about" do > get :about > assert_response :success > assert_select "title", "About | Ruby on Rails Tutorial Sample App" > end > > test "should get contact" do > get :contact > assert_response :success > assert_select "title", "Contact | Ruby on Rails Tutorial Sample App" > end > end > > > application.html.erb > > > > > <%= full_title(yield(:title)) %> > <%= stylesheet_link_tag'application', media: 'all', > 'data-turbolinks-track' => > true %> > <%= javascript_include_tag 'application', 'data-turbolinks-track' => > true %> > <%= csrf_meta_tags %> > > > <%= yield %> > > > > > routes.rb > Rails.application.routes.draw do > root 'static_pages#home' > > get 'static_pages/help' > > get 'static_pages/about' > > get 'static_pages/contact' > > How do I get past this problem? Is there a way to fix this? > > BTW, the error is listed here: 1) Failure: StaticPagesControllerTest#test_should_get_about [C:/Sites/sample_app/test/controllers/static_pages_controller_test.rb:19]: expected but was . Expected 0 to be >= 1. 2) Failure: StaticPagesControllerTest#test_should_get_contact [C:/Sites/sample_app/test/controllers/static_pages_controller_test.rb:25]: expected but was . Expected 0 to be >= 1. 3) Failure: StaticPagesControllerTest#test_should_get_help [C:/Sites/sample_app/test/controllers/static_pages_controller_test.rb:13]: expected but was . Expected 0 to be >= 1. 4) Failure: StaticPagesControllerTest#test_should_get_home [C:/Sites/sample_app/test/controllers/static_pages_controller_test.rb:7]: expected but was . Expected 0 to be >= 1. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/30850e77-fa6c-4f16-8fcb-bf0d21626a46%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[Rails] My program does not work after adding helpler
I have just gotten to Chapter Four of Michael Hartl's Ruby on Rails Tutorial, and I can't seem to get the program to work after adding a helper to the program. Here is the code from the files. static_pages_controller_test.rb require 'test_helper' class StaticPagesControllerTest < ActionController::TestCase test "should get home" do get :home assert_response :success assert_select "title", "Ruby on Rails Tutorial Sample App" end test "should get help" do get :help assert_response :success assert_select "title", "Help | Ruby on Rails Tutorial Sample App" end test "should get about" do get :about assert_response :success assert_select "title", "About | Ruby on Rails Tutorial Sample App" end test "should get contact" do get :contact assert_response :success assert_select "title", "Contact | Ruby on Rails Tutorial Sample App" end end application.html.erb <%= full_title(yield(:title)) %> <%= stylesheet_link_tag'application', media: 'all', 'data-turbolinks-track' => true %> <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> <%= csrf_meta_tags %> <%= yield %> routes.rb Rails.application.routes.draw do root 'static_pages#home' get 'static_pages/help' get 'static_pages/about' get 'static_pages/contact' How do I get past this problem? Is there a way to fix this? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/948a8411-846c-48bf-8553-9366a6ae1f3c%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[Rails] Re: Puts just work on Controllers
Damaris Fuentes wrote: > Taking a look through Google I found that some people have the same > problem, but most of them because they have changed from Webrick to > Mongrel. Apparently, console with mongrel does not show the "puts" > messages. However, I am working with webrick. I'm getting the same issue, and I'm using lightppd. Way back I had some simple output to console type of thing, and I'm sure at the time I used print. That would have been on webrick back then. I'm going to follow this thread as I'd like to know what the trick is. I fI find out before you, I'll post back. -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: rails.vim -> killing the server?
Thin is just another webserver for ruby apps (mongrel, webrick, thin, ...) http://code.macournoyer.com/thin/ You could've done :Rscript server to accomplish the same Rick Lloyd is describing (which would default to whatever server you're using). On Sun, May 3, 2009 at 9:04 PM, 7stud -- wrote: > > Rick Lloyd wrote: > > I don't understand, when I issue the rails.vim command > > ":Rscript server thin" > > the thin server is started in the current VIM window with > > output visible. > > What's a 'thin server'? As I mentioned in my op, this is what I had > been doing in Terminal: > > /myapp$ ruby script/server > > The window then showed the log output from the server. I could kill the > sever by hitting Ctrl+C. > > The rails.vim help says this: > > :Rserver {options} Launches script/server {options} in the background. > On win32, this means |!start|. On other systems, this > uses the --daemon option. > > > /myapp$ ruby script/server -h > > Usage: server [options] >-p, --port=port Runs Rails on the specified port. > Default: 3000 >-b, --binding=ip Binds Rails to the specified ip. > Default: 0.0.0.0 >-c, --config=fileUse custom rackup configuration > file >-d, --daemon Make server run as a Daemon. >-u, --debugger Enable ruby-debugging for the > server. >-e, --environment=name Specifies the environment to run > this server under (test/development/production). > Default: development >-P, --path=/path Runs Rails app mounted at a > specific path. > Default: / > >-h, --help Show this help message. > > Nothing about 'thin' in there. > > > > The behavior is identical to that in a terminal > > window which has has the command "script/server thin" issued. > > > > i.e. I can see the output from the thin server as if I were tailing > > the logfile and I can stop the thin server by issuing a Ctrl-C in the > > VIM window (vimdoh?). > > > > Doesn't this accomplish what you're after? > > I don't know. I'll have to try it the next time I am ready to logout. > -- > Posted via http://www.ruby-forum.com/. > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: rails.vim -> killing the server?
The issue is that rails.vim starts the server with the --daemon option, so it just sits there in the background. :Rserver! will try to kill it first, and restart it from vim, but I'd just use the terminal for controlling your server during development. On May 3, 11:59 am, 7stud -- wrote: > Harold wrote: > > I don't have a mac, but this is pure unix and should be applicable to > > you as well. > > > Get the PID of the server process and kill it manually: > > $ ps aux |grep ruby > > hgimenez 30736 24.8 1.6 48772 33252 pts/0 Sl+ 11:22 0:03 ruby > > script/server > > hgimenez 30802 0.0 0.0 4204 704 pts/1 S+ 11:22 0:00 grep > > ruby > > $ > > > In my case, you want to kill process 30736. Same thing could be > > achieved with pgrep: > > > $ pgrep ruby > > 30736 > > $ > > > But if you have many ruby processes going on, you won't know which one > > to kill. > > > Now that you have the process ID, kill it: > > > $ kill 30736 > > $ > > > The server should be gone, and you should be able to start the server > > again on the same port: > > $ ps auxwww |grep ruby > > $ script/server [...] > > > Hope that helps, > > -Harold > > Yes, I'm aware that you can do that --although I don't have enough unix > experience to kill processes I'm not sure about. > > I was hoping that there was a simple command in rails.vim that I could > use. I pored over the rails.vim help, but I can't find anything. I'm > certainly not going to run the server in rails.vim ever gain unless I > can find an easy way to kill it after I've started it. > > -- > Posted viahttp://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: rails.vim -> killing the server?
I don't have a mac, but this is pure unix and should be applicable to you as well. Get the PID of the server process and kill it manually: $ ps aux |grep ruby hgimenez 30736 24.8 1.6 48772 33252 pts/0Sl+ 11:22 0:03 ruby script/server hgimenez 30802 0.0 0.0 4204 704 pts/1S+ 11:22 0:00 grep ruby $ In my case, you want to kill process 30736. Same thing could be achieved with pgrep: $ pgrep ruby 30736 $ But if you have many ruby processes going on, you won't know which one to kill. Now that you have the process ID, kill it: $ kill 30736 $ The server should be gone, and you should be able to start the server again on the same port: $ ps auxwww |grep ruby $ script/server [...] Hope that helps, -Harold On May 3, 7:48 am, 7stud -- wrote: > In macvim, I started the server like this: > > :Rserver > > But I'm trying to debug something in my application, and I want to use > puts to output a message in the server's output window. Before > installing macvim and rails.vim, I kept a Terminal window open where I > started the server using: > > /myapp$ruby script/server > > and the server(Mongrel) would log output to the window about what it was > doing. Then if I used puts in my program, the output would go to the > server window, and I could examine it. > > I want to set up a separate Terminal window for the sever like before, > so I can examine the server's output, but I can't figure out how to kill > the server I started in macvim/rails.vim. If I try to start a server in > Terminal, I get an "address already in use" error: > > /myap$ ruby script/server > => Booting Mongrel > => Rails 2.3.2 application starting onhttp://0.0.0.0:3000 > => Call with -d to detach > => Ctrl-C to shutdown server > Exiting > /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/tcphack.rb:12:in > `initialize_without_backlog': Address already in use - bind(2) > (Errno::EADDRINUSE) > > I tried closing every macvim and Terminal window, quitting the macvim > and Terminal programs, and shutting down Firefox, then relaunching > Terminal. But I when I open a Terminal window and try to start the > server using: > > /myapp$ ruby script/server > > I get the same error message: "address already in use". Here is what > the top command produces: > > $ top > --- > PID COMMAND %CPU TIME #TH #PRTS #MREGS RPRVT RSHRD RSIZE > VSIZE > 1200 top 6.9% 0:06.71 1 18 20 544K 428K 1.01M > 27.0M > 1195 bash 0.0% 0:00.01 1 14 16 220K 824K 804K > 27.1M > 1194 login 0.0% 0:00.00 1 16 40 172K 508K 660K > 26.9M > 1192 Terminal 1.0% 0:02.26 4 90 142 1.99M 10.7M+ 8.01M+ > 231M+ > 1167 ruby 0.1% 0:04.17 2 10 132 20.3M 2.59M 21.7M > 50.4M > 1141 lookupd 0.0% 0:00.19 2 34 38 464K 1.02M 1.26M > 28.5M > 1138 MDCPdUSB 0.0% 0:00.01 1 23 20 312K 772K 996K > 27.1M > 1136 pppd 0.0% 0:00.04 1 26 30 332K 1.02M 1.43M > 27.4M > 1130 mdimport 0.0% 0:00.33 4 65 56 1.23M 3.67M 4.08M > 39.7M > 357 Preview 0.0% 0:00.36 1 69 118 1.73M 7.95M 6.29M > 225M > 217 AppleSpell 0.0% 0:01.45 1 44 34 700K 3.18M 2.37M > 37.8M > 214 Safari 0.0% 29:11.21 9 298 3311 407M 52.6M 323M > 700M > 207 automount 0.0% 0:00.01 3 39 30 308K 924K 1.09M > 28.7M > 203 automount 0.0% 0:00.01 3 41 34 316K 956K 1.13M > 29.0M > 200 rpc.lockd 0.0% 0:00.00 1 10 17 124K 452K 220K > 26.7M > 191 nfsiod 0.0% 0:00.00 5 30 24 124K 352K 208K > 28.6M > > - > > That ruby process looks suspicious. I don't know what that is. > > Currently, the only way that I can kill the server is to reboot my > computer, which is not very convenient. > -- > Posted viahttp://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: MacVim and rails.vim not working
It is misleading, I'll give you that...but for future reference, the process you just went through will be very similar with any vim plugin. On Thu, Apr 30, 2009 at 6:34 PM, 7stud -- wrote: > > 7stud -- wrote: > > Harold wrote: > >> Should be simple: The "rails" folder should not be present under > >> your .vim folder. > > > > Stupid maintainer. > > > > I have a question about that: when you unzip a file isn't there a > container directory? When I untar a file, all the files end up in a > master directory. So when the maintainer says to extract the zip file > to ~/.vim/ isn't that incorrect? > -- > Posted via http://www.ruby-forum.com/. > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: MacVim and rails.vim not working
On Thu, Apr 30, 2009 at 6:10 PM, 7stud -- wrote: > > Harold wrote: > > Should be simple: The "rails" folder should not be present under > > your .vim folder. > > Stupid maintainer. Excuse me? > > > > > > > Move the plugin, doc and autoload files individually > > to each of the subfolders of .vim, so that the tree looks like this: > > > > .vim > > | > > --autoload > > | | > > | --rails.vim > > --doc > > | | > > | --rails.txt > > --plugin > >| > >--rails.vim > > > > I actually tried that earlier, but the tutorial I was following said to > test rails.vim out by issuing the following command: > > :Rails mynewapp > > and this is what I got/get: > > :!rails newapp > /bin/bash: line 1: rails: command not found Well, is rails installed (as a gem, not frozen in your app). In your terminal, can you do rails --version, or which rails ? > > > shell returned 127 > > But this works now: > > :Rcontroller products So, the rails.vim plugin is up and running... There is also a rails-vim google group: http://groups.google.com/group/vim-on-rails > > > > > > -- > Posted via http://www.ruby-forum.com/. > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Integrate test process with Rspec and Cucumber in a plugin using Desert
Are you require'ing all of the files it can't find inside spec_helper? I've never done anything with Desert, but sounds like the files aren't being required. Some code would help diagnose the issue. On Apr 30, 11:12 am, romain endelin wrote: > Hello, I'm developing some rails plugins with desert, and I would like > to use tests with RSpec and Cucumber in the development. RSpec is > integrated by default in Desert plugins, but it gives me some bugs. > Finally I have created a minimal application which use my plugin, and > I try to test it like a normal application without plugin. But I > dislike that solution, the plugin lost its modularity, and RSpec still > returns me some bugs (he can't find the models/views/controllers > located in the plugin...). > So has anyone ever tried to test a Desert plugin (or even in a classic > plugin) and could get solutions to those matters ? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: how to search all fields for a string in SQL ?
I would suggest going with the thinkingsphinx plugin instead of ultrasphinx. Thinkingsphinx's syntax is much cleaner. http://ts.freelancing-gods.com/usage.html http://railscasts.com/episodes/120-thinking-sphinx On the other hand, if your dataset is small enough, you could try scoped-search, which helps you construct the SQL to perform your searches: http://wiki.github.com/wvanbergen/scoped_search But as Robert said, databases/SQL are not great for this type of queries and you may not be able to scale much when you have many conditions and/or big volumes of data. On Apr 30, 4:54 pm, Robert Walker wrote: > wbsurf...@yahoo.com wrote: > > Using SQL or activerecord I am not sure how to search all fields for a > > specific value ? > > I know how to do this by just writing ruby code. To do it in SQL or an > > activerecord find w/condition, > > I don't know how. I actually am supposed to combine an find w/ > > condition and a search all fields for a > > value and AND those together. I think perhaps it can't be done with a > > single find ? > > What you're probably looking for is a full-text search engine. Here's an > article I found using the Sphinx engine: > > http://www.neeraj.name/blog/articles/599-working-with-sphinx-fulltext... > > If you needs are pretty basic and you don't mind a database specific > implementation you can also look at MySQL's full-text search > capabilities. SQL was just not designed for such queries. > -- > Posted viahttp://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: MacVim and rails.vim not working
Should be simple: The "rails" folder should not be present under your .vim folder. Move the plugin, doc and autoload files individually to each of the subfolders of .vim, so that the tree looks like this: .vim | --autoload | | | --rails.vim --doc | | | --rails.txt --plugin | --rails.vim Here's my vim config, as a reference: http://github.com/hgimenez/vimfiles/tree/master -H On Apr 30, 4:13 pm, 7stud -- wrote: > Hi, > > I'm having trouble getting rails.vim working. Unzipping the rails.vim > download on my Desktop produced a rails folder with this structure: > > rails > ---autoload > -rails.vim > ---doc > -rails.txt > ---plugin > -rails.vim > > I moved that directory to ~/.vim > > $ mv /Users/me/Desktop/rails ~/.vim/rails > > $ cd ~/.vim > ~/.vim$ ls > filetype.vim rails syntax > $ cd rails > [au...@cws-computer.local] ~/.vim/rails$ ls > autoload doc my_note.txt plugin > > Then a tutorial I read said if I start macvim and issue the command > > :Rails testapp > > that should create a new app. But I get this error: > > E492 Not an editor command: Rails testapp > > I also tried this cd'ing into the top level of an existing app and > starting macvim: > > /depot$ mvim > > and then in macvim typing: > > :Rcontroller products > > and I get the same error. What am I doing wrong? > -- > Posted viahttp://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Rspec
The rspec site has good documentation: http://rspec.info/documentation/ But I would suggest you read other people's code and buy the rspec book (currently in beta). If you had any specific issue we might be able to help. On Apr 22, 6:06 am, Shakthi Murugan wrote: > Hi, > > Any one help me to write test cases using rspec send some related > links that contains basic steps or some sample application test cases... > -- > Posted viahttp://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Problems with Rails and Postgres
What kind of error do you get, exactly? On Apr 16, 1:10 pm, Rafael Roque wrote: > Hi all, > > i have a method that I use in the 'after_save' that is implemented as > follows: > > def verify > a =11674 > x = self.aui_codigo > > reinc =AutoInfracao.find_by_sql("select age((select aui_data_lav > from tb_aui_auto_infracao where aui_codigo=#{a}), > (select max(aui_data_lav)from tb_aui_auto_infracao where aui_codigo > in(select a.aui_codigo from tb_aur_auto_inf_regular a,tb_iau_itens_auto > i where a.for_cod =(select for_cod from tb_aur_auto_inf_regular where > aui_codigo=#{a}) and a.lir_codigo=(select lir_codigo from > tb_aur_auto_inf_regular where aui_codigo = #{a}) and i.inf_codigo = > (select inf_codigo from tb_iau_itens_auto where aui_codigo = #{a}) and > a.aui_codigo<>#{a} and a.aui_codigo = i.aui_codigo)))") > > print reinc[0].age > end > > the 'a' and the 'x' variables have the same value(11674) and the same > type(FixNum).Curiously,I can run my query using the 'a' variable,but I > cannot run it using the 'x' variable.What am I doing wrong? > -- > Posted viahttp://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Testing and SQL views.
I use postgres, mostly. You want to implement rules. From the create view docs: "Currently, views are read only: the system will not allow an insert, update, or delete on a view. You can get the effect of an updatable view by creating rules that rewrite inserts, etc. on the view into appropriate actions on other tables. For more information see *CREATE RULE*<http://www.postgresql.org/docs/8.2/static/sql-createrule.html> ." You are expecting Rails to take care of something that it should not be concerned/aware of. Create the "CRUD" rules on your postgres views, and as far as rails is concerned, they are just tables, or even better, "a thing where active record persists data"... On Fri, Apr 17, 2009 at 8:57 AM, Tim Uckun wrote: > > > On Sat, Apr 18, 2009 at 12:43 AM, Harold A. Giménez Ch. < > harold.gime...@gmail.com> wrote: > >> What DBMS are you using? The alternative is a "materialized view". >> > > postgres. > > >> >>>> >>>> Name the fixtures.yml file after the actual target table, not the view. >>>> >>>> >>> I'll give that a shot. Thanks... >>> >>> > > This didn't work. There are no fixtures with the names of the views and the > test suite still tries to run a delete from the views. > > I can't believe rails has no conception of views. Must be the mysql > heritage (I know mysql has views now). > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Testing and SQL views.
What DBMS are you using? The alternative is a "materialized view". On Fri, Apr 17, 2009 at 8:42 AM, Tim Uckun wrote: > > >> >> Name the fixtures.yml file after the actual target table, not the view. >> >> > I'll give that a shot. Thanks... > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: query pulling too many fields
The find's :select option is ignored when you combine it with the :include option. On Apr 16, 8:58 pm, Scott Kulik wrote: > i'm a little confused here on what's happening. > > i have two tables ITEMS and ITEM_TYPES > > ITEMS (belongs_to :item_type) > id > name > item_type_id > > ITEM_TYPES > id > name > > here is my Item.rb model code for my query: > > find(:all, > :select => 'items.name, item_types.name', > :include => :item_type, > :conditions => ['item_types.name = ? OR item_types.name = ? OR > item_types.name = ? OR item_types.name = ?', 'Material', 'Weapon', > 'Armor', 'Accessory'], > :order => 'items.name') > > currently it is selecting all fields in the ITEM table and not using the > :select that i have entered. > > if i comment out the :conditions parameter the :select works properly. > i'm sure it's something to do with the linking to the item_types table. > does anyone know how i can get the above :select working properly? > > thanks! > -- > Posted viahttp://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: New to Ruby on Rails
The page you're getting is just a default error page for production environments. How are you starting the server? ruby script\server? Try adding RAILS_ENV=development to that command: ruby script\server RAILS_ENV=development In the development environment, the page shown when an error occurs should be more informative for the developer, showing some debugging information and stack trace. Regardless of environment, try looking at your logs which should show some information that point you on the right direction. In this case, I suspect you'll see something around the route "/garbage" not being defined or found, but your logs should tell you exactly what's going on. Hope that helps, -Harold On Apr 16, 5:16 am, "saravanan@gmail.com" wrote: > Hi > > I have installed ruby186-26 using this > linkhttp://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html?page=1 > > While i am trying to use thishttp://127.0.0.1:3000/garbage/ > > It says > > We're sorry, but something went wrong. > > We've been notified about this issue and we'll take a look at it > shortly. > > in the browser. What is the problem? > > Saravanan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: SQL Server via DBI/ODBC configuration
Mike, in my experience this has been painful. Here's a few things to look for: First, make sure that TDS is set up fine. Verify it with this command: tsql -S server -U user -P password Make sure you have ruby-odbc to have ruby load the ODBC driver (think this could potentially solve your issue). My instructions on a fedora box are: RubyODBC: wget http://ch-werner.de/rubyodbc/ruby-odbc-0.9996.tar.gz tar -xvzpf ruby-odbc-0.9996.tar.gz cd ruby-odbc-0.9996 ruby extconf.rb make sudo make install Test it out again. If you have a problem with the data source, a way to test it directly is: isql -v datasource username password Hope that helps, -Harold On Apr 14, 7:21 pm, mvargo wrote: > Dear Chris, > > Thank you for reponding. I tried that. I get the same error from a > different stack. It finds the new sqlserver.rb from the gem you > suggested. But it still barfs in DBI because it can't find the ODBC > driver. I wonder if it's some kind of path thing for finding the dbd- > odbc thing. It's beyond my rails capabilities to figure out how the > gems find each other. I'm sure it's some lame thing (it always is!). > > Any other advice would be greatly appreciated. > > Mike > > >> subscriber = Subscriber.find(1) > > DBI::InterfaceError: Unable to load driver 'ODBC' > from /usr/lib/ruby/gems/1.8/gems/dbi-0.4.0/lib/dbi.rb:286:in > `load_driver' > from /usr/lib/ruby/1.8/monitor.rb:242:in `synchronize' > from /usr/lib/ruby/gems/1.8/gems/dbi-0.4.0/lib/dbi.rb:236:in > `load_driver' > from /usr/lib/ruby/gems/1.8/gems/dbi-0.4.0/lib/dbi.rb:154:in > `_get_full_driver' > from /usr/lib/ruby/gems/1.8/gems/dbi-0.4.0/lib/dbi.rb:139:in > `connect' > from /home/mvargo/.gem/ruby/1.8/gems/rails-sqlserver-2000-2005- > adapter-2.2.15/lib/active_record/connection_adapters/ > sqlserver_adapter.rb:26:in `sqlserver_connection' > > On Apr 14, 11:22 am, Chris Johnson wrote: > > > Try this gem out, works for me I think your on the right > > path...http://github.com/rails-sqlserver/2000-2005-adapter/tree/master > > > On Tue, Apr 14, 2009 at 12:29 PM, mvargo wrote: > > > > I have followed the cookbook on > > >http://wiki.rubyonrails.org/database-support/ms-sql > > > but am having problems with the rails part. I can connect to the > > > database using sqsh so I think all the freetds plumbing is good. When > > > I try to connect to the db with a rake db:migrate or just using script/ > > > console I get this error: > > > > >> Client.find(:first) > > > DBI::InterfaceError: Unable to load driver 'ODBC' > > > from /usr/lib/ruby/gems/1.8/gems/dbi-0.4.0/lib/dbi.rb:286:in > > > `load_driver' > > > from /usr/lib/ruby/1.8/monitor.rb:242:in `synchronize' > > > from /usr/lib/ruby/gems/1.8/gems/dbi-0.4.0/lib/dbi.rb:236:in > > > `load_driver' > > > from /usr/lib/ruby/gems/1.8/gems/dbi-0.4.0/lib/dbi.rb:154:in > > > `_get_full_driver' > > > from /usr/lib/ruby/gems/1.8/gems/dbi-0.4.0/lib/dbi.rb:139:in > > > `connect' > > > from /usr/lib/ruby/gems/1.8/gems/activerecord-sqlserver- > > > adapter-1.0.0.9250/lib/active_record/connection_adapters/ > > > sqlserver_adapter.rb:47:in `sqlserver_connection' > > > from > > > /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/ > > > connection_adapters/abstract/connection_pool.rb:223:in `send' > > > from > > > /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/ > > > connection_adapters/abstract/connection_pool.rb:223:in > > > `new_connection' > > > > database.yml is: > > > > development: > > > adapter: sqlserver > > > mode: ODBC > > > dsn: CONTENT_STORE > > > username: joebob > > > password: secret > > > > So I looked into dbi.rb and I see where it throws the exception. It > > > can't seem to get the Driver called ODBC. I do have dbd-odbc-0.2.4 > > > installed. Seems like the dbi part is not connecting to the odbc > > > part. > > > > Rails is running on ubuntu 8.1. > > > > Any pointers would be very welcome. > > > > Sincerely, > > > > Mike Vargo > > > > *** LOCAL GEMS *** > > > > actionmailer (2.3.2) > > > actionpack (2.3.2) > > > activerecord (2.3.2) > > > activerecord-sqlserver-adapter (1.0.0.9250) > > > activeresource (2.3.2) > > > activesupp
[Rails] Re: Ridiculously Slow View Rendering
To be honest, I really don't know what's going on, but I would try commenting out the image_tag. First of all, it is probably causing another trip to the DB per user. Second, I don't know how heavy the images are, but using height and width may be hiding the fact that they're big, and you're just using html to scale them down on your view. Do you see similar results when completely removing the images on that _user partial? On Mon, Apr 6, 2009 at 5:10 PM, Avishai wrote: > > When I leave the params off and just go for a straight index, I'm > still seeing this: > > Processing UsersController#index [GET] > Parameters: {"action"=>"index", "controller"=>"users"} > User Load (5.6ms) SELECT * FROM `users` ORDER BY users.created_at > DESC LIMIT 0, 10 > SQL (0.4ms) SELECT count(*) AS count_all FROM `users` > Rendering template within layouts/application > Rendering users/index > Rendered users/_user (432.4ms) > Rendered users/_user (133.4ms) > Rendered users/_user (96.1ms) > Rendered users/_user (202.4ms) > Rendered users/_user (26.1ms) > Rendered users/_user (55.6ms) > Rendered users/_user (51.3ms) > Rendered users/_user (21.8ms) > Rendered users/_user (38.3ms) > Rendered users/_user (47.9ms) > User Load (9.3ms) SELECT * FROM `users` WHERE (`users`.`id` = 1) > LIMIT 1 > Rendered users/_search (67.1ms) > SQL (3.8ms) SELECT count(*) AS count_all FROM `messages` WHERE > (`messages`.receiver_id = 1 AND (`messages`.`read` = 0)) > Rendered users/_user_bar (134.7ms) > Completed in 1861ms (View: 1534, DB: 19) > > I had thought that it had something had to do with the size of the > about_me as mentioned before, but I checked again, and some of those > long-rendering user partials had no content for the about_me field... > > Any other ideas as to why this could be taking so long to render? > > Thanks a lot > > Avishai > > On Apr 6, 2:55 pm, Avishai wrote: > > I tried a bunch of different searches, and it's actually loading > > reasonably quickly still... < 500ms at least. > > > > Also, in the process I upgraded from Rails 2.2.1 to 2.3.2, so maybe > > that helped somewhat too. > > > > -Avishai > > > > On Apr 6, 2:13 pm, Harold A. Giménez Ch. > > wrote: > > > > > This is good to know. > > > "Completed in 319ms (View: 288, DB: 27)" > > > 319ms is not hardly close to your original 11386ms. > > > > > I notice that your params below do not have any of the "search" > criteria > > > ([:user][:interests], etc). If you run the view using the criteria, > does > > > performance degrade? > > > > > On Mon, Apr 6, 2009 at 1:50 PM, Avishai > wrote: > > > > > > Fred, I took your suggestion to up the log level and this is what it > > > > reveals: > > > > > > Processing UsersController#index [GET] > > > > Parameters: {"action"=>"index", "controller"=>"users", "page"=>"11"} > > > > User Load (26.0ms) SELECT * FROM `users` ORDER BY users.created_at > > > > DESC LIMIT 100, 10 > > > > SQL (0.2ms) SELECT count(*) AS count_all FROM `users` > > > > Rendering template within layouts/application > > > > Rendering users/index > > > > Rendered users/_user (3.7ms) > > > > Rendered users/_user (2.9ms) > > > > Rendered users/_user (3.1ms) > > > > Rendered users/_user (42.6ms) > > > > Rendered users/_user (39.6ms) > > > > Rendered users/_user (121.2ms) > > > > Rendered users/_user (32.9ms) > > > > Rendered users/_user (4.9ms) > > > > Rendered users/_user (14.7ms) > > > > Rendered users/_user (2.7ms) > > > > User Load (0.2ms) SELECT * FROM `users` WHERE (`users`.`id` = 1) > > > > LIMIT 1 > > > > Rendered users/_search (3.0ms) > > > > Rendered users/_user_bar (2.1ms) > > > > Completed in 319ms (View: 288, DB: 27) > > > > > > However, once I hit refresh a bunch of times, all those partials drop > > > > to only a few ms each. Including the ones that show as 40, 120, etc > > > > above. Those long ones all had text in the about_me > > > > > > -Avishai > > > > > > On Apr 6, 1:37 pm, Avishai wrote: > > > > > Interesting. Maybe something is going on in the controller. I've > tried > > > > > running the resulting SQL queries directly, and they still seem to > be > > > > >
[Rails] Re: Ridiculously Slow View Rendering
This is good to know. "Completed in 319ms (View: 288, DB: 27)" 319ms is not hardly close to your original 11386ms. I notice that your params below do not have any of the "search" criteria ([:user][:interests], etc). If you run the view using the criteria, does performance degrade? On Mon, Apr 6, 2009 at 1:50 PM, Avishai wrote: > > Fred, I took your suggestion to up the log level and this is what it > reveals: > > Processing UsersController#index [GET] > Parameters: {"action"=>"index", "controller"=>"users", "page"=>"11"} > User Load (26.0ms) SELECT * FROM `users` ORDER BY users.created_at > DESC LIMIT 100, 10 > SQL (0.2ms) SELECT count(*) AS count_all FROM `users` > Rendering template within layouts/application > Rendering users/index > Rendered users/_user (3.7ms) > Rendered users/_user (2.9ms) > Rendered users/_user (3.1ms) > Rendered users/_user (42.6ms) > Rendered users/_user (39.6ms) > Rendered users/_user (121.2ms) > Rendered users/_user (32.9ms) > Rendered users/_user (4.9ms) > Rendered users/_user (14.7ms) > Rendered users/_user (2.7ms) > User Load (0.2ms) SELECT * FROM `users` WHERE (`users`.`id` = 1) > LIMIT 1 > Rendered users/_search (3.0ms) > Rendered users/_user_bar (2.1ms) > Completed in 319ms (View: 288, DB: 27) > > However, once I hit refresh a bunch of times, all those partials drop > to only a few ms each. Including the ones that show as 40, 120, etc > above. Those long ones all had text in the about_me > > -Avishai > > On Apr 6, 1:37 pm, Avishai wrote: > > Interesting. Maybe something is going on in the controller. I've tried > > running the resulting SQL queries directly, and they still seem to be > > fetching pretty quickly... > > > > The controller contains a lot of conditionals, maybe that's the issue? > > I've used Newrelic RPM to analyze my SQL, and it looks like for > > everything there's no USING FILESYSTEM, so indexes are set up > > properly... The about_me column is a regular freetext column (TEXT i > > think), so the length varies anywhere from zero to a few paragraphs of > > text. The photos are handled with paperclip, but are just URLs, not > > the actual files in the DB. Could it still be a bandwidth still be an > > issue DB => webserver if they're on the same box? > > > > Controller code is at the end here:http://gist.github.com/90786 > > > > Cheers, > > > > Avishai > > > > On Apr 6, 12:50 pm, Harold wrote: > > > > > I can't find anything fundamentally wrong on your views, but we > > > haven't seen any controller and model code. > > > > > Try benchmarking/profiling your app to find out exactly what the > > > bottleneck is. Seehttp:// > guides.rubyonrails.org/performance_testing.html > > > > > A good start may be your DB. What RDMS are you using? Do you have > > > proper indexes? > > > Have you tried running the SQL directly (pick it up from the logs) and > > > finding out if it's a problem with Rails at all? > > > How big is the user.about_me column be? If it's huge you may be > > > hitting a bandwidth bottleneck (DB => web server). > > > > > Not much more occurs to me at this point, but hope that points you on > > > the right direction. > > > > > On Apr 6, 11:14 am, Avishai wrote: > > > > > > Hi, > > > > > > I've been experiencing some severe slowness in rendering the views in > > > > my users/index action. It's really not doing anything fancy at all, > > > > and has been driving me nuts the last few days. I'm running Rails > > > > 2.2... does anyone have any idea how to resolve this? Look at home > > > > much time is being consumed by the view. Obviously those response > > > > times are unacceptable, and this is with 3 instances of Thin running > > > > in production on a VPS... > > > > > > #production.log > > > > Rendering users/index > > > > Completed in 11386ms (View: 8693, DB: 151) > > > > > > Rendering users/index > > > > Completed in 5024ms (View: 3286, DB: 16) > > > > > > Rendering users/index > > > > Completed in 11692ms (View: 8811, DB: 105 > > > > > > Rendering users/index > > > > Completed in 11184ms (View: 8116, DB: 364) > > > > > > Rendering sessions/new > > > > Completed in 1696ms (View: 1012, DB: 0) > > > > > > Rendering users/ind
[Rails] Re: Ridiculously Slow View Rendering
I can't find anything fundamentally wrong on your views, but we haven't seen any controller and model code. Try benchmarking/profiling your app to find out exactly what the bottleneck is. See http://guides.rubyonrails.org/performance_testing.html A good start may be your DB. What RDMS are you using? Do you have proper indexes? Have you tried running the SQL directly (pick it up from the logs) and finding out if it's a problem with Rails at all? How big is the user.about_me column be? If it's huge you may be hitting a bandwidth bottleneck (DB => web server). Not much more occurs to me at this point, but hope that points you on the right direction. On Apr 6, 11:14 am, Avishai wrote: > Hi, > > I've been experiencing some severe slowness in rendering the views in > my users/index action. It's really not doing anything fancy at all, > and has been driving me nuts the last few days. I'm running Rails > 2.2... does anyone have any idea how to resolve this? Look at home > much time is being consumed by the view. Obviously those response > times are unacceptable, and this is with 3 instances of Thin running > in production on a VPS... > > #production.log > Rendering users/index > Completed in 11386ms (View: 8693, DB: 151) > > Rendering users/index > Completed in 5024ms (View: 3286, DB: 16) > > Rendering users/index > Completed in 11692ms (View: 8811, DB: 105 > > Rendering users/index > Completed in 11184ms (View: 8116, DB: 364) > > Rendering sessions/new > Completed in 1696ms (View: 1012, DB: 0) > > Rendering users/index > Completed in 8361ms (View: 6898, DB: 107) > > #users/index.html.erb > > Users > <%= render :partial => "users/user", :collection => @users %> > <%= will_paginate @users %> > <% if @users.empty? -%> > Looks like we couldn't find > anything matching your search. Maybe you should consider broadening it? > > <% end -%> > > > #_user.html.erb > <% div_for user do %> > <%= link_to(image_tag(user.photo.url(:small), :alt => > user.login, :height => 130, :width => 130, :class => "profile-photo"), > user) %><%= link_to(user.login, user) %> > <%= user.age %> / <%= user.sex %> / < > %= user.city %>, <%= user.state %> > <%= truncate_words(user.about_me || > "", 80) -%> > <% end %> > > The template code is here too:http://gist.github.com/90786 > > Any ideas? > > Thanks! > > Avishai --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Rails VS. .Net MVC
To me it's mostly about the Open Source culture: Not only Rails, but the entire stack as many have pointed out. Open source is not only about free (as in beer), but the freedom to do whatever the heck you want with it - for instance, deploy on nginx with mongrel, or thin, or passenger, under any number of VMs and OSes, as well as databases. This is the kind of freedom you get on an open source environment, much unlike Microsoft. By using .Net MVC, not only are you locking your "VM" to the .Net framework (not sure if Mono is a viable option), but also you would have to deploy on the windows stack, and get ready to pay for licensing fees for both Windows Server and SQL Server. It does add up, especially if/when you scale horizontally. Be sure to bring this up when they make the point the MS .Net MVC was recently open sourced. The Rails community has lead the path in web development industry with practices like TDD and BDD, DRY, YAGNI, convention over configuration, full integration with javascript frameworks enabling the use of Ajax, etc. These are certainly possible and encouraged by other frameworks, but Rails lead that path and made it real and tangible. Finally, Ruby is just a joy to work with. I firmly believe that it helps developers write shippable code faster, and with less bugs. Blocks and procs make life more enjoyable. Not having to write BS code to simply call something on each element of an array, by example, just talks for itself: Here's a brief example: for (int i = 0; i < my_array.length; i++) { my_array[i].something() } Or: my_array.map(&:something) Same goes with the dynamic nature of the language and how it makes meta-programming accessible... The bottom line is that by using Ruby (and Rails), you will most likely be able to develop new features quicker, you and your team will be happier, and you'll have a broader set of deployment options for your apps. What's most important for the business is getting features out the door, with as few bugs as possible, and being able to maintain them throughout the life cycle of the product. In this sense, Rails delivers. Good luck, -H On Apr 3, 5:18 pm, Mark Turner wrote: > On Apr 3, 12:04 pm, Chris Johnson wrote: > > > I have been put in a tough situation at work. I have been developing rails > > applications for the past 2 years and thoroughly enjoy what I am doing. > > However it has been bestowed upon me to give an objective summary leading to > > the benefits of rails versus using Microsoft's MVC capabilities. > > > I have been going back and forth with colleges on this and everyone has a > > response to how "their" technology is better. I am looking for some other > > ideas / reasons why you people in the community like rails as a way to > > gather more evidence of to why we should use rails in an "enterprise" (the > > buzz word everyone around here uses) environment. > > > Any opinions are greatly welcomed. I love rails and dont want to go down > > with out a fight but need some good ammo and am looking for the community > > for advice as a way to answer the question "Why is Rails better"? > > You could throw all sorts of reasons at their feet and I still worry > that for the most part it would be falling on deaf ears. There have > been countless time I have heard people completely throw any non- > Microsoft, IBM or HP solution out the door because of some pre- > existing ideals they have. Its way less common today but still very > prevalent. > > Rails is a mature framework, ruby is a fantastic language but for the > most part it still expects you to have a clue about what you're doing. > It takes a few hats to be able to develop, test and host a rails app. > In the .net world everything (mostly) is going to be hosted/done > Microsoft's way... its hard to fight a fight like this if you are the > only one fighting for rails, phb's want to be able to fire you and > call Microsoft when they need help. To be honest I would assume that > someone in a leadership position over a developer using rails would > have seen value in it by now, which leads me to think that the boss > has no clue and is easily swayed by any marketing documents. Rails is > very opinionated and has choice some positions on things that not > everyone else agrees with, and the beauty of that is people were > passionate enough to go out and create their own frameworks instead of > accepting what the core team decides. > > Like I said, Rails is a mature well supported framework for developing > web applications. Ruby if a great language and has only gotten better > since a large group of developers started to use it when the moved to > rails. Rails is open & ruby is open you have a choice when it comes to > runtimes and hosting environments. If you get into metaprogramming and > then try some of the fantastic things you're able to do in ruby with a > language like c# you're going to be disappointed. > > Ultimately I would say that it comes down to you, what do you wa
[Rails] Re: Nil being coerced to float
All you need to do to your original code is add a condition to make sure @payments is not null: @payment_total = @payments.sum{ |payment| payment.value } unless @payments.nil? Or can payment.value be nil for some payments but not others? Inject could help in that case: @payment_totals = @payments.inject(0) { |sum, p| sum + p.value unless p.value.nil? } Before running either one of these, you can initialize both @total and @payment_total to zero: @total, @payment_total = 0, 0 Hope that helps. PS: Wonder if you need all of these to be @instance_variables ? On Apr 1, 10:16 am, Tom Harvey wrote: > I was doing this: > > �...@line_items = LineItems.find_all_by_invoice_id(params[:id]) > �...@payments = Payments.find_all_by_invoice_id(params[:id]) > > @total = @line_items.sum{ |item| item.cost } > @payment_total = @payments.sum{ |payment| payment.value } > > @balance = @total - @payment_total > > But when no payments had been made it was coming up with an error when > trying to sum nil, so I did this: > > begin > @payment_total = @payments.sum{ |payment| payment.value } > rescue > @payment_total = 0 > end > > So, when the sum failed it returned @payment_total as zero. Now, SURELY, > there's a better way to do this? I'm sure it's obvious when you know > how. Please, enlighten me. > -- > Posted viahttp://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: rearranging the letters of a word
# Based on: # http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/139290 # Author: Endy Tjahjono class String def perm return [self] if self.length < 2 ret = [] 0.upto(self.length - 1) do |n| #rest = self.split('') rest = self.split(//u)# for UTF-8 encoded strings picked = rest.delete_at(n) rest.join.perm.each { |x| ret << picked + x } end ret end end p "abc".perm #=> ["abc", "acb", "bac", "bca", "cab", "cba"] On Apr 1, 8:44 am, "railsb...@gmail.com" wrote: > Hello there, > > I have to rearrange the letters of a word in all possible ways in > my rails application.I am not getting the exact way doing so, please > can anybody help me in developing that logic. > > Thank you in advance. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: OOP road block
I think this is a common 'dilemma' that comes across every now and then. "Which model should I ask for this information"? I also think there's no right answer. But here's my two cents: In your case, you want to know which a product was purchased by a user, so the question could go both ways: Did a user purchase this product, or was this product purchased by the user. I think it depends on your views and controllers, in other words, what is the main object you find out the relationship about? If you're on a user view and want to list purchased products, you might just ask @user.orders.each { |o| o.products }.flatten (or some such thing). Similarly, @product.orders.each { |o| o.user }.flatten would give you all users who purchased that product. (this is all making some assumptions about your relationships). In either case, you are working with either an instance of User, or an instance of Product, so I think that that this should not be a class method, but an instance method. Same goes when you're already dealing with a user instance and a product instance and you want to find out if that relationship exists, which is more to the point of your original post. How about an instance method on the User class called has_purchased?: @user.has_purchased?(@product) => true #or false Here's a stab at that method... #class User < AR:Base def has_purchased?(product) !self.orders.products.find_by_id(product).nil? end About joins, I think they are absolutely needed. Some models are more "self contained" than others, but since you're working with a relational model, it is natural that some models depend on others, and using :joins or :include in your finders makes life easier in many cases... On Apr 1, 5:05 am, Fernando Perez wrote: > I think the problem lies in the ability for the DB to perform a join > across multiple tables which in fact breaks encapsulation! > > Maybe I should break down my DB query that uses joins into smaller > queries. The code is obviously less efficient, but it's more > maintainable, as each model is only concerned with its own stuff, and > therefore I don't have to make edits across various models just because > I changed the name or type of attributes in a single model. > > Using joins across multiple models doesn't feel right anymore. > -- > Posted viahttp://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Use fixtures within fixtures?
The finder call to the DB is redundant. How about you save yourself the trip to the db and just do one-en: id: <%= Fixtures.identify(:one) -%> locale: en name: cars On Sun, Mar 29, 2009 at 9:15 AM, Heinz Strunk < rails-mailing-l...@andreas-s.net> wrote: > Oh, I thought I could call that fixture from the other file directly so > I guess the only thing I can do is > > category_translations.yml > one-en: > id: <%= Category.find_by_id(Fixtures.identify(:one)) %> > locale: en > name: Cars > > one-es: > id: <%= Category.find_by_id(Fixtures.identify(:one)) %> > locale: es > name: Coches > ...? > -- > Posted via http://www.ruby-forum.com/. > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Use fixtures within fixtures?
I don't get that...it doesn't really look at any other yml, it just calculates a hash: >> Fixtures.identify(:one) => 953125641 >> Fixtures.identify(:two) => 996332877 How are you calling this? -H On Mar 28, 2:34 pm, Heinz Strunk wrote: > Um well... I use two different yml-files so it doesn't find the > identifiers from the other files. How do I tell him to look in the other > one? > -- > Posted viahttp://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Use fixtures within fixtures?
How about using erb? <%= find_by_id() %> On Mar 28, 1:41 pm, Heinz Strunk wrote: > Heya, > > I'm using globalize2 and have following problem with my fixtures: > > categories.yml: > one: > parent_id: two > color: #ff00aa > > two: > color: #00ff11 > > three: > parent_id: two > color: #ab00ab > > category_translations.yml > one-en: > id: one > locale: en > name: Cars > > one-es: > id: one > locale: es > name: Coches > > two-en: > id: two > locale: en > name: Start > > two-es: > id: two > locale: es > name: Inicio > > three-en: > id: three > locale: en > name: Bicycles > > three-es: > id: three > locale: es > name: Bicicletas > > My problem now is that in my translations table all id's are NULL which > is kinda obvious cause the fixture has no idea where one, two and three > is. Does anyone know how to load a fixture inside a fixture in order to > use them? > -- > Posted viahttp://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Adding a css stylesheet to a plugin
I don't think it is a good idea to try to 'auto-load' a css. The css is used in a layout, but it's up to the user to specify which layout or layouts she wants to use your plugin in. Also, your css rules may colide with someone else's code and if you auto-load it, it would be very hard to catch and debug. I would instead use your plugin's install.rb to move the css to public/ stylesheets, and include instructions on how to include the CSS in layouts. My $0.02. On Mar 27, 3:51 am, Davide Benini wrote: > Hello folks, > I am creating a simple RoR plugin, mostly to teach myself the art of > plugin-coding. > The plugin is mostly a helper plugin, generating HTML code. > Now I would like to include a CSS stylesheet ; the idea is to supply a > "my_plugin_css" helper to print a link to the css stylesheet in the > template head, but if there is a way to auto-load a css (that is, > withoutb the plugin user intervention) I'd be happy to use it. > Anyway, my main problem now is telling rails to load my css file as if > it was in the usual "plublic/stylesheet" folder. > Any suggestion? > Davide > -- > Posted viahttp://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Hash with key and value from ActiveRecord?
I actually don't get the OP's use of the hash method in this context: http://www.ruby-doc.org/core/classes/Array.html#M002182 It seems that it's just computing the hash, and the block passed is just being silently ignored... Heniz, using your code what's the output of @attributes.inspect and @attributes.class.name? On Mar 25, 8:33 am, Frederick Cheung wrote: > On Mar 25, 11:46 am, Heinz Strunk > wrote: > > > > > @attributes = Attribute.find_all_by_character_id(@character).hash { > > |u| [u.name, u.value] } > > > and I would like to access it like > > > @attributes[:health] > > > but it doesn't work. Anyone can help me out with that? > > The keys of your hash are strings, not symbols. (be careful with an > instance variable called @attributes if this is in an instance method > - you would overwrite activerecord's instance variable of the same > name) > > Fred > > > -- > > Posted viahttp://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Hash with key and value from ActiveRecord?
Try this: @attributes = Hash[*Attribute.find_all_by_character_id(@character).map { |a| [a.name, a.value] }.flatten] On Mar 25, 7:46 am, Heinz Strunk wrote: > Heya, > > I think I have thinking barrier. I just want a simple hash out of an > ActiveRecord. > > @attributes = Attribute.find_all_by_character_id(@character).hash { > |u| [u.name, u.value] } > > and I would like to access it like > > @attributes[:health] > > but it doesn't work. Anyone can help me out with that? > -- > Posted viahttp://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: OCR project in Gsoc
There are many ways to accomplish this, none of them are easy... There's ai4r's backpropagation nueural nets implementation, with a simple OCR example at http://ai4r.rubyforge.org/neuralNetworks.html There's also gnu Ocrad, which I've never used: http://www.gnu.org/software/ocrad/, and just found http://gtamilocr.sourceforge.net/ which does OCR for Tamil characters as well. I'd be glad to hear other suggestions... On Mar 24, 11:36 am, Arulalan wrote: > Hi to all, > > I planned to do project in gsoc... For OCR ( Optimal Character > Recoganisation ) ... > > That is ,,, > > If we scanning one full text page from book, it will open > into open office as word format. so that we can edit the page from > scanned text page... I planned to convert scanned letters to words for > Tamil, English Languages... I will try to support few more languages > also...This OCR project will can done by Using Rmagick , i will do > this successfully. > > This is my idea, if any one of you can suggest me and > guide me to do this... > > Thank, > > Arulalan. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Charts in Rails
> You must have glossed over the OP's requirements indeed I did. My apologies. On Fri, Mar 20, 2009 at 1:58 PM, Robert Walker < rails-mailing-l...@andreas-s.net> wrote: > > Harold wrote: > > There's plenty out there, Fusion charts free and open flash charts > > being my top choices. > > You must have glossed over the OP's requirements. Namely that Flash > charts were not an option. > -- > Posted via http://www.ruby-forum.com/. > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Charts in Rails
There's plenty out there, Fusion charts free and open flash charts being my top choices. This InfoQ article includes Fusion Charts in their comparison: http://www.infoq.com/articles/sharma-charts-in-rails Open Flash Charts: http://teethgrinder.co.uk/open-flash-chart/ http://www.pullmonkey.com/projects/open_flash_chart2 On Mar 20, 3:49 am, motine wrote: > gnuplot doesn't really look nice and the flash / js / css solutions do > not really fit my requirement of creating charts on the server side. > I found Eastwood (http://www.jfree.org/eastwood/) which emulates > Google Charts but you may run it on your own server. This is quite a > good solution, but I do not really like the idear of having to run a > servlet container. > > any further idears? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: very simple authenticatation
The logic is wrong. Try this: def authenticateAdmin authenticate_or_request_with_http_basic do |name, password| credentials = {'admin' => 'admin', 'slt' => 'slt'} credentials[name] == pasword end end On your previous examples, your method was returning 'the last thing evaluated' (a Ruby thing), and in your case, that happened to be 'slt'. 'slt', as a string, is not false, which is why your method was letting users in regardless of credentials. Hardcoded credentials in any app are a terrible idea though... On Mar 19, 5:07 pm, johnsonmlw wrote: > Thanks for the suggestion. > > I get the same problem. *Any* username or password is allowed. > > So I can enter 'foo' and no password and it let's me in. > > Odd. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: generate csv from ruby object
Ruports is pretty slick: http://rubyreports.org/ On Mar 19, 1:55 pm, Dhaval Phansalkar wrote: > hi all, > > is there any method/way to generate a csv from an object directly? e.g. > @object.to_csv that will create a csv file with whatever data that > object holds? > > the object that i have is a parsed xml response like @report = parsed > xml. but i'm not able to send it to csv as number of > columns,rows,headings are not fixed. this object holds report data. > thanks in advance. > > -Dhaval > -- > Posted viahttp://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Date-conventions
I've always followed: *_on => some date *_at => some datetime I rarely ever use date only fields though. Sure you don't want to store the purchase date _and_ time? Up to you of course... On Mar 19, 5:11 am, Sebastian Joecks wrote: > hey all > i got a (hopefully) simple question.. > > i want to name a datetype. now i started thinking about, if its > > purchased_at > > or > > purchased_on ? > > its only a date and not a datetime... > > ty > Sebastian > -- > Posted viahttp://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Find all messages from all friends
> Any comments on the performance from anyone? Don't worry about it until it's a problem. YAGNI. But then again, you can do caching, paginate, intelligently use ajax to load only what's needed, etc. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: do not understand collect method use wit property
They are both equivalent in terms of functionality. The first is a common rails idiom: @some_collection.collect(&:id) or @some_collection.map(&:id) #I've seen this one used more than collect... The ampersand syntax is simply telling the interpreter that the symbol is the block parameter to the method. Internally the to_proc method of the symbol class is called. Here's a reference: http://apidock.com/rails/Symbol/to_proc Beware, doing @foo.map(&:id) doesn't perform as well as @foo.map { |f| f.id } for big numbers of foos... Also note that this is a Rails only feature (ie: try it on plain irb and it will not work). On Mar 11, 1:35 pm, Hiro Protagonist wrote: > Hi all, > Can someone explain to me in terms of ruby why this works? > > Story.find_all_by_user_id(2).collect(&:link) # 1 method call > > This is in ROR console. link is a property of Story. The above command > finds all db rows and all their properties (columns) with user_id == 2 > and creates an array with only the link property. > > This is same as: > Story.find_all_by_user_id(2).collect{|x| x.link} # 2 block > > I understand function #2 with use of a block. > > I do not understand function #1 in terms of syntax. What is &:link? I > know it represents a property and could accept that this is the way it > works but I want to understand this in terms of ruby syntax. Is &:link > a block? If so it would have to represent x.link. I do not understand > how this is generated in ruby. > > TIA, > Pete > -- > Posted viahttp://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Rails cross platform problem
This is related to the fact that on *nix the default end of line character is \n, and on windows, it's \r\n (note that this is not Ruby specific, but platform specific - Ruby is just following along). There's a utility on unixes called unix2dos which you can use to substitute all \n characters to \r\n, or if you need to stay in Ruby- land, use gsub with something like gsub!(/\n/,"\r\n"). Hope that helps, -H On Mar 9, 8:43 pm, Zhao Yi wrote: > My Rails working on a Linux system and a client access this server from > Windows. The client inputs something in a text area and click submit, in > the server side, it put the input into a file. The problem is that at > the end of each line in the file, there is a "^M". How can I avoid this? > I use File.puts method to write to the file. > > thanks. > -- > Posted viahttp://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Newb question...get info from the db
OK Great... You were calling the + method, which concatenates two string objects, on a User object. In your original code, the @login variable did not hold a string object, but a user object (returned by the call to User.find_by_login( ... ). Ruby was rightfully complaining that the + method was not defined on the user object. @user.login returns a string, which does have the + method and therefore you can concatenate with the rest of your string (in the flash message). On Mon, Mar 9, 2009 at 7:59 PM, Chris Gunnels < rails-mailing-l...@andreas-s.net> wrote: > > Harold wrote: > > In that case, try: > > > > class MemberController < ApplicationController > > def index > > @user= User.find_by_login(params[:l]) > > flash[:notice] = @user.login + ", you've logged in successfully" > > end > > end > > > > > > > > On Mar 9, 7:24�pm, Chris Gunnels > > Your changes worked...What was I doing wrong? > -- > Posted via http://www.ruby-forum.com/. > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Newb question...get info from the db
In that case, try: class MemberController < ApplicationController def index @user= User.find_by_login(params[:l]) flash[:notice] = @user.login + ", you've logged in successfully" end end On Mar 9, 7:24 pm, Chris Gunnels wrote: > > Rails' default is that the table name is a plural version of the model > > name. That's because the Model typically represents a single record > > from a table. So the table named Users holds lots of records that are > > access via the User model. > > Im sorry the table name is users...here is the error message: > NoMethodError in MemberController#index > > undefined method `+' for # > > RAILS_ROOT: C:/Ruby/MyProjects/ipod-give-away.com > Application Trace | Framework Trace | Full Trace > > C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/attribute_methods.rb:260:in > `method_missing' > app/controllers/member_controller.rb:4:in `index' > > Request > > Parameters: > > {"l"=>"ballhogjoni"} > > Show session dump > > Response > > Headers: > > {"cookie"=>[], > "Content-Type"=>"", > "Cache-Control"=>"no-cache"} > -- > Posted viahttp://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: No error but mail not sent?
Without knowing what your SMTP server is, not much we can do. One generic way is with telnet. A search for "telnet smtp send email" gives you this post: http://blogs.crsw.com/mark/archive/2006/07/06/2032.aspx Also, try locating the mail server's logs and see if that points you on the right direction. Hope that helps, -Harold On Mon, Mar 9, 2009 at 5:13 PM, Guillaume Loader < rails-mailing-l...@andreas-s.net> wrote: > > I don't know? How can I try? > -- > Posted via http://www.ruby-forum.com/. > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Application access for non-Rails developers
Access to what? The source code? On Mar 9, 4:14 pm, Ian wrote: > I was wondering if anyone gives non-developers access to their Rails > applications (like say a tech-savvy content manager or designer) and > if so, how? What software? etc. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: No error but mail not sent?
Get Rails out of the equation. Can you have your local smtp server send out emails directly, without using Rails? On Mar 9, 4:50 pm, Guillaume Loader wrote: > No I'm in local so I use localhost. Am I wrong? > -- > Posted viahttp://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Protecting an associated record from destroying -- How To and explanation?
Another option is using the before_destroy callback to do the check: http://apidock.com/rails/ActiveRecord/Callbacks/before_destroy On Mon, Mar 9, 2009 at 9:27 AM, Ar Chron wrote: > > vimal wrote: > > Then i removed the pattern which was used by a schedule. > > How can i avoid this action. > > > > As the old family physician used to say, "If it hurts, don't do it." > > If you want to protect against pattern deletion, you could just > eliminate the destroy method from the Pattern controller, and make the > Pattern destroy happen only through the "parent" Schedule destroy. > > -- > Posted via http://www.ruby-forum.com/. > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: How can I get the current url i'm looking at?
You can always look at your browser's address bar or bookmark it. Or, within the context of Rails, http://api.rubyonrails.org/classes/ActionController/AbstractRequest.html#M000469 On Feb 16, 2:38 pm, John Smith wrote: > How can I get the current url i'm looking at? I need it to return there > later. > -- > Posted viahttp://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Looking for a tool do visualize the data model of a rails application
I found that schemaSpy was really helpful in visualizing and sharing any database's ER diagram... http://schemaspy.sourceforge.net/ On Feb 16, 7:41 am, ms wrote: > Hey, > > I'm looking for a tool which allows me to visualize the data model of > a rails application in uml diagrams. In the moment, I manually > synchronize my uml diagrams and the ror models manually, but this > takes too much time. > > Thanks for any suggestions! > ms --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Two-to-one mappings
>From what I understand, one competitor will have as many rooms as RoundCombinations. Your room definition below would return the first one it finds. I think you can do something like: @competitor.rounds.each { |round| round.round_combination.room } Would return an array of rooms for each of @competitor's rounds. That sound right? On Sun, Feb 15, 2009 at 7:48 PM, Greg wrote: > > Ah, sorry, my specification was not very good. The Big Picture here > is that we assign each Competitor to a room based on the particular > combination of Rounds he or she is signed up for. So for example, we > could have > > r = RoundCombination.new > r.room = room_1 > r.rounds = [round_1, round_2] > r.save > > Now if c is a Competitor who is signed up for round_1 and round_2, I > would like to be able to do > > c.room > #=> room_1 > > So essentially, a HABTM table does not seem to be the right way of > capturing this relationship. A Competitor "knows" its > RoundCombination because the Competitor is signed up for a particular > combination of Rounds. I've managed a provisional, rather inefficient > implementation, of c.room as > > class Competitor < ActiveRecord::Base > has_many :rounds > > def room >RoundCombination.all.each do |rc| > return rc.room if rc.rounds.sort_by {|r| r.id} == rounds.sort_by > {|r| r.id} >end >nil > end > end > > I feel this should be done with some SQL joins or something. Does > Rails provide a relationship to manage this? > > Thanks again, > > Greg > > > On Feb 15, 6:06 pm, "Harold A. Gimenez" > wrote: > > Actually, by user I mean competitor, but you get the point... > > > > -Original Message- > > From: Harold > > Reply-to: rubyonrails-talk@googlegroups.com > > To: Ruby on Rails: Talk > > Subject: [Rails] Re: Two-to-one mappings > > Date: Sun, 15 Feb 2009 14:55:27 -0800 (PST) > > > > Does a user have many round_combinations? and a round_combination has > > many users? Seems like it. If so, first thought is to create another > > HABTM table between round_combinations and users. Then > > @user.round_combinations.each { |rc| rc.room } gives you the rooms... > > > > On Feb 15, 11:16 am, Greg wrote: > > > Ah, so one follow up question: each Competitor in the competition is > > > signed up for two rounds, and needs to know which room he or she is > > > assigned. This is a has_one relationship; however, I'm not quite sure > > > of the right way to map it. Thoughts? > > > > > Greg > > > > > On Feb 15, 2:49 am, Harold A. Giménez Ch. > > > wrote: > > > > > > Great! Glad it worked. > > > > > > On Sun, Feb 15, 2009 at 1:57 AM, Greg > wrote: > > > > > > > Cool! Harold, your solution strikes me as being exactly the way to > do > > > > > it. I've implemented it, and things seem to be sailing smoothly. > > > > > Thanks a lot to both of you. > > > > > > > Sincerely, > > > > > > > Greg > > > > > > > On Feb 14, 11:47 pm, Harold wrote: > > > > > > That's a clean solution, however I don't know if it satisfies the > fact > > > > > > that "any Room might have many different combinations of Rounds" > > > > > > > > Not sure I understand correctly, but if a room can have many > > > > > > combination of rounds, and each combination of rounds has more > than > > > > > > one round, you could try this: > > > > > > > > Room and Round models I assume you already have. A room can have > many > > > > > > round_combinations (create the RoundCombination model with a > room_id. > > > > > > Room :has_many :room_combinations, and > > > > > > RoomCombination :belongs_to :room). Then create a join table > between > > > > > > round_combinations and rounds (HABTM). > > > > > > > > You can use callbacks or validation to limit the relationship to > two > > > > > > rounds maximum. > > > > > > > > On Feb 14, 11:42 pm, Maurício Linhares < > mauricio.linha...@gmail.com> > > > > > > wrote: > > > > > > > > > Imagining that every round must belong to a room, here's a > simple and > > > > > > > straightforward implementation: > > > > > > > > > class Room < ActiveRecord::Base > > >
[Rails] Re: Two-to-one mappings
Actually, by user I mean competitor, but you get the point... -Original Message- From: Harold Reply-to: rubyonrails-talk@googlegroups.com To: Ruby on Rails: Talk Subject: [Rails] Re: Two-to-one mappings Date: Sun, 15 Feb 2009 14:55:27 -0800 (PST) Does a user have many round_combinations? and a round_combination has many users? Seems like it. If so, first thought is to create another HABTM table between round_combinations and users. Then @user.round_combinations.each { |rc| rc.room } gives you the rooms... On Feb 15, 11:16 am, Greg wrote: > Ah, so one follow up question: each Competitor in the competition is > signed up for two rounds, and needs to know which room he or she is > assigned. This is a has_one relationship; however, I'm not quite sure > of the right way to map it. Thoughts? > > Greg > > On Feb 15, 2:49 am, Harold A. Giménez Ch. > wrote: > > > Great! Glad it worked. > > > On Sun, Feb 15, 2009 at 1:57 AM, Greg wrote: > > > > Cool! Harold, your solution strikes me as being exactly the way to do > > > it. I've implemented it, and things seem to be sailing smoothly. > > > Thanks a lot to both of you. > > > > Sincerely, > > > > Greg > > > > On Feb 14, 11:47 pm, Harold wrote: > > > > That's a clean solution, however I don't know if it satisfies the fact > > > > that "any Room might have many different combinations of Rounds" > > > > > Not sure I understand correctly, but if a room can have many > > > > combination of rounds, and each combination of rounds has more than > > > > one round, you could try this: > > > > > Room and Round models I assume you already have. A room can have many > > > > round_combinations (create the RoundCombination model with a room_id. > > > > Room :has_many :room_combinations, and > > > > RoomCombination :belongs_to :room). Then create a join table between > > > > round_combinations and rounds (HABTM). > > > > > You can use callbacks or validation to limit the relationship to two > > > > rounds maximum. > > > > > On Feb 14, 11:42 pm, Maurício Linhares > > > > wrote: > > > > > > Imagining that every round must belong to a room, here's a simple and > > > > > straightforward implementation: > > > > > > class Room < ActiveRecord::Base > > > > > # this class needs a max_rounds and rounds_count integer columns > > > > > has_many :rounds > > > > > > def accepts_more_rounds? > > > > > max_rounds < rounds_count > > > > > end > > > > > > end > > > > > > class Round < ActiveRecord::Base > > > > > # this class needs a room_id integer column > > > > > belongs_to :room, :counter_cache => true > > > > > > validate_on_create :validate_rounds_count > > > > > > protected > > > > > > def validate_rounds_count > > > > > self.room.reload > > > > > unless self.room.accepts_more_rounds? > > > > > errors.add( :room, "has already met it's rounds limit" ) > > > > > end > > > > > end > > > > > > end > > > > > > room = Room.create( :max_rounds => 2 ) > > > > > round_1 = room.rounds.create( :name => 'round 1' ) > > > > > round_2 = room.rounds.create( :name => 'round 2' ) > > > > > round_3 = room.rounds.create( :name => 'round 3' ) # this one isn't > > > > > going to be created > > > > > round_3.new_record? == true > > > > > > - > > > > > Maurício > > > > > Linhareshttp://alinhavado.wordpress.com/(pt-br)<http://alinhavado.wordpress.com/%28pt-br%29>| > > >http://blog.codevader.com/(en) <http://blog.codevader.com/%28en%29> > > > > > > On Sat, Feb 14, 2009 at 7:53 PM, Greg Brockman > > > > > > wrote: > > > > > > > Hey all, > > > > > > > I have a pretty simple question, but I'm not sure of a good solution > > > > > > to it. Essentially, I want to provide a two-to-one mapping of > > > models. > > > > > > I'm working on an application for a contest, where every > > > > > > (unordered) > > > > > > combination of two Rounds is supposed to be assigned to one Room. > > > Any > > > > > > Room might have many different combinations of Rounds, however. > > > > > > > What is the Right Way of doing this in Rails? Maybe create a model > > > > > > that holds the associated foreign keys? Also, what would be a good > > > > > > way to scale this out, if I wanted to be able to map unordered > > > > > > n-element collections of Rounds to obtain a Room? > > > > > > > Thanks, > > > > > > > Greg --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Two-to-one mappings
Does a user have many round_combinations? and a round_combination has many users? Seems like it. If so, first thought is to create another HABTM table between round_combinations and users. Then @user.round_combinations.each { |rc| rc.room } gives you the rooms... On Feb 15, 11:16 am, Greg wrote: > Ah, so one follow up question: each Competitor in the competition is > signed up for two rounds, and needs to know which room he or she is > assigned. This is a has_one relationship; however, I'm not quite sure > of the right way to map it. Thoughts? > > Greg > > On Feb 15, 2:49 am, Harold A. Giménez Ch. > wrote: > > > Great! Glad it worked. > > > On Sun, Feb 15, 2009 at 1:57 AM, Greg wrote: > > > > Cool! Harold, your solution strikes me as being exactly the way to do > > > it. I've implemented it, and things seem to be sailing smoothly. > > > Thanks a lot to both of you. > > > > Sincerely, > > > > Greg > > > > On Feb 14, 11:47 pm, Harold wrote: > > > > That's a clean solution, however I don't know if it satisfies the fact > > > > that "any Room might have many different combinations of Rounds" > > > > > Not sure I understand correctly, but if a room can have many > > > > combination of rounds, and each combination of rounds has more than > > > > one round, you could try this: > > > > > Room and Round models I assume you already have. A room can have many > > > > round_combinations (create the RoundCombination model with a room_id. > > > > Room :has_many :room_combinations, and > > > > RoomCombination :belongs_to :room). Then create a join table between > > > > round_combinations and rounds (HABTM). > > > > > You can use callbacks or validation to limit the relationship to two > > > > rounds maximum. > > > > > On Feb 14, 11:42 pm, Maurício Linhares > > > > wrote: > > > > > > Imagining that every round must belong to a room, here's a simple and > > > > > straightforward implementation: > > > > > > class Room < ActiveRecord::Base > > > > > # this class needs a max_rounds and rounds_count integer columns > > > > > has_many :rounds > > > > > > def accepts_more_rounds? > > > > > max_rounds < rounds_count > > > > > end > > > > > > end > > > > > > class Round < ActiveRecord::Base > > > > > # this class needs a room_id integer column > > > > > belongs_to :room, :counter_cache => true > > > > > > validate_on_create :validate_rounds_count > > > > > > protected > > > > > > def validate_rounds_count > > > > > self.room.reload > > > > > unless self.room.accepts_more_rounds? > > > > > errors.add( :room, "has already met it's rounds limit" ) > > > > > end > > > > > end > > > > > > end > > > > > > room = Room.create( :max_rounds => 2 ) > > > > > round_1 = room.rounds.create( :name => 'round 1' ) > > > > > round_2 = room.rounds.create( :name => 'round 2' ) > > > > > round_3 = room.rounds.create( :name => 'round 3' ) # this one isn't > > > > > going to be created > > > > > round_3.new_record? == true > > > > > > - > > > > > Maurício > > > > > Linhareshttp://alinhavado.wordpress.com/(pt-br)<http://alinhavado.wordpress.com/%28pt-br%29>| > > >http://blog.codevader.com/(en) <http://blog.codevader.com/%28en%29> > > > > > > On Sat, Feb 14, 2009 at 7:53 PM, Greg Brockman > > > > > > wrote: > > > > > > > Hey all, > > > > > > > I have a pretty simple question, but I'm not sure of a good solution > > > > > > to it. Essentially, I want to provide a two-to-one mapping of > > > models. > > > > > > I'm working on an application for a contest, where every > > > > > > (unordered) > > > > > > combination of two Rounds is supposed to be assigned to one Room. > > > Any > > > > > > Room might have many different combinations of Rounds, however. > > > > > > > What is the Right Way of doing this in Rails? Maybe create a model > > > > > > that holds the associated foreign keys? Also, what would be a good > > > > > > way to scale this out, if I wanted to be able to map unordered > > > > > > n-element collections of Rounds to obtain a Room? > > > > > > > Thanks, > > > > > > > Greg --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Two-to-one mappings
Great! Glad it worked. On Sun, Feb 15, 2009 at 1:57 AM, Greg wrote: > > Cool! Harold, your solution strikes me as being exactly the way to do > it. I've implemented it, and things seem to be sailing smoothly. > Thanks a lot to both of you. > > Sincerely, > > Greg > > On Feb 14, 11:47 pm, Harold wrote: > > That's a clean solution, however I don't know if it satisfies the fact > > that "any Room might have many different combinations of Rounds" > > > > Not sure I understand correctly, but if a room can have many > > combination of rounds, and each combination of rounds has more than > > one round, you could try this: > > > > Room and Round models I assume you already have. A room can have many > > round_combinations (create the RoundCombination model with a room_id. > > Room :has_many :room_combinations, and > > RoomCombination :belongs_to :room). Then create a join table between > > round_combinations and rounds (HABTM). > > > > You can use callbacks or validation to limit the relationship to two > > rounds maximum. > > > > On Feb 14, 11:42 pm, Maurício Linhares > > wrote: > > > > > Imagining that every round must belong to a room, here's a simple and > > > straightforward implementation: > > > > > class Room < ActiveRecord::Base > > > # this class needs a max_rounds and rounds_count integer columns > > > has_many :rounds > > > > > def accepts_more_rounds? > > > max_rounds < rounds_count > > > end > > > > > end > > > > > class Round < ActiveRecord::Base > > > # this class needs a room_id integer column > > > belongs_to :room, :counter_cache => true > > > > > validate_on_create :validate_rounds_count > > > > > protected > > > > > def validate_rounds_count > > > self.room.reload > > > unless self.room.accepts_more_rounds? > > > errors.add( :room, "has already met it's rounds limit" ) > > > end > > > end > > > > > end > > > > > room = Room.create( :max_rounds => 2 ) > > > round_1 = room.rounds.create( :name => 'round 1' ) > > > round_2 = room.rounds.create( :name => 'round 2' ) > > > round_3 = room.rounds.create( :name => 'round 3' ) # this one isn't > > > going to be created > > > round_3.new_record? == true > > > > > - > > > Maurício > > > Linhareshttp://alinhavado.wordpress.com/(pt-br)<http://alinhavado.wordpress.com/%28pt-br%29>| > http://blog.codevader.com/(en) <http://blog.codevader.com/%28en%29> > > > > > On Sat, Feb 14, 2009 at 7:53 PM, Greg Brockman > > > > > wrote: > > > > > > Hey all, > > > > > > I have a pretty simple question, but I'm not sure of a good solution > > > > to it. Essentially, I want to provide a two-to-one mapping of > models. > > > > I'm working on an application for a contest, where every (unordered) > > > > combination of two Rounds is supposed to be assigned to one Room. > Any > > > > Room might have many different combinations of Rounds, however. > > > > > > What is the Right Way of doing this in Rails? Maybe create a model > > > > that holds the associated foreign keys? Also, what would be a good > > > > way to scale this out, if I wanted to be able to map unordered > > > > n-element collections of Rounds to obtain a Room? > > > > > > Thanks, > > > > > > Greg > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Two-to-one mappings
That's a clean solution, however I don't know if it satisfies the fact that "any Room might have many different combinations of Rounds" Not sure I understand correctly, but if a room can have many combination of rounds, and each combination of rounds has more than one round, you could try this: Room and Round models I assume you already have. A room can have many round_combinations (create the RoundCombination model with a room_id. Room :has_many :room_combinations, and RoomCombination :belongs_to :room). Then create a join table between round_combinations and rounds (HABTM). You can use callbacks or validation to limit the relationship to two rounds maximum. On Feb 14, 11:42 pm, Maurício Linhares wrote: > Imagining that every round must belong to a room, here's a simple and > straightforward implementation: > > class Room < ActiveRecord::Base > # this class needs a max_rounds and rounds_count integer columns > has_many :rounds > > def accepts_more_rounds? > max_rounds < rounds_count > end > > end > > class Round < ActiveRecord::Base > # this class needs a room_id integer column > belongs_to :room, :counter_cache => true > > validate_on_create :validate_rounds_count > > protected > > def validate_rounds_count > self.room.reload > unless self.room.accepts_more_rounds? > errors.add( :room, "has already met it's rounds limit" ) > end > end > > end > > room = Room.create( :max_rounds => 2 ) > round_1 = room.rounds.create( :name => 'round 1' ) > round_2 = room.rounds.create( :name => 'round 2' ) > round_3 = room.rounds.create( :name => 'round 3' ) # this one isn't > going to be created > round_3.new_record? == true > > - > Maurício Linhareshttp://alinhavado.wordpress.com/(pt-br) > |http://blog.codevader.com/(en) > > On Sat, Feb 14, 2009 at 7:53 PM, Greg Brockman > > wrote: > > > Hey all, > > > I have a pretty simple question, but I'm not sure of a good solution > > to it. Essentially, I want to provide a two-to-one mapping of models. > > I'm working on an application for a contest, where every (unordered) > > combination of two Rounds is supposed to be assigned to one Room. Any > > Room might have many different combinations of Rounds, however. > > > What is the Right Way of doing this in Rails? Maybe create a model > > that holds the associated foreign keys? Also, what would be a good > > way to scale this out, if I wanted to be able to map unordered > > n-element collections of Rounds to obtain a Room? > > > Thanks, > > > Greg --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Schedule job in rails
No quite like that. If you're sending an HTTP GET request to any URL, you would pass parameters to the URL itself, something like: http://localhost:3000/cron?param1=value1¶m2=value2 etc What looks attractive to me about this approach (of using wget via cron instead of a rake task) is that you are not bringing up an entire rails environment to handle a task. There's less overhead. Just be sure to lock it down with a combination of things that have been suggested here: IP Address check, local_request?, http basic authentication. There may be more you can do... On Sat, Feb 14, 2009 at 12:52 AM, Valentino Lun < rails-mailing-l...@andreas-s.net> wrote: > > >> wget http://localhost:3000/cron > >> > >> cron_controller invokes your method > > > > Thanks, it is a very good idea. How about if my action require 2 > > parameters? How to do that? > > Let me further elabroate on my question. For example in my Cron > Controller > > def someaction > some_method(params[:one],params[:two]) > end > > Is it possible to do this in my crontab as follow? > > 10 10 * * * wget http://localhost:3000/cron/someaction "para1" "para2" > > Many thanks > > Valentino > -- > Posted via http://www.ruby-forum.com/. > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Schedule job in rails
That's a great idea, until someone in the outside finds out about that path/resource. You're opening up too much and scriptkiddies can get happy attempting a DoS. Wondering if you handle that somehow (IP address check or something)? -Original Message- From: Mario Gutierrez Reply-to: rubyonrails-talk@googlegroups.com To: rubyonrails-talk@googlegroups.com Subject: [Rails] Re: Schedule job in rails Date: Fri, 13 Feb 2009 16:55:27 +0100 I use cron to schedule wget: wget http://localhost:3000/cron cron_controller invokes your method --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Schedule job in rails
Especially if this method is accessing your models, I don't see a way around loading your entire rails environment. I think a more common solution would be to create a rake task which you invoke with cron... On Feb 12, 10:53 pm, Valentino Lun wrote: > Dear all > > I tried script/runner for this, but every execution need to initialize > the rails environment. Any other good idea for it? What is your > good/best practice? > > Many thanks > > Valentino > -- > Posted viahttp://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Best Way to detect if you are in a migration?
I recently posted a similar question. No answer... http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/5d38a62129fa63e4/a78671aa145bf278?hl=en#a78671aa145bf278 On Feb 9, 3:11 pm, Frantisek Psotka wrote: > I im interested in this question, has somebody the answer? > -- > Posted viahttp://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: get # of errors in error_messages_for
Haven't tried this, but how about "#{User.errors.size} errors, please ..." On Feb 5, 10:33 pm, Johnroy World wrote: > i need a solution my friend. any help or advice would be appreciated. > Thank you > -- > Posted viahttp://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: detecting rake db:migrate ?
Thanks! That would work, for now. I still have the itch though. If anyone knows, do tell. Thanks again, -H On Thu, Feb 5, 2009 at 4:22 PM, Ryan Bigg wrote: > > There is a model class method like table_exists? That you can use to > check ifthe table exists and then only run the code if it does > > > > On 06/02/2009, at 6:51, Harold wrote: > > > > > Excuse me, the code I need to wrap around the check is on > > ApplicationController. Still, any ideas? > > > > On Feb 5, 3:33 pm, Harold wrote: > >> Hi group, > >> > >> I have a line of code in environment.rb that cannot be run during a > >> rake db:migrate, as it depends on some tables being present. > >> > >> I need to find a way to enclose this line in a check for > >> db:migrate. I > >> know how to check if we're in a rake task with: > >> > >> unless defined?(Rake) > >> # do stuff, but skip when run from rake tasks > >> end > >> > >> How can I take this further to make check if I'm running the rake > >> db:migrate task? > >> > >> Thanks, > >> > >> -H > > > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: detecting rake db:migrate ?
Excuse me, the code I need to wrap around the check is on ApplicationController. Still, any ideas? On Feb 5, 3:33 pm, Harold wrote: > Hi group, > > I have a line of code in environment.rb that cannot be run during a > rake db:migrate, as it depends on some tables being present. > > I need to find a way to enclose this line in a check for db:migrate. I > know how to check if we're in a rake task with: > > unless defined?(Rake) > # do stuff, but skip when run from rake tasks > end > > How can I take this further to make check if I'm running the rake > db:migrate task? > > Thanks, > > -H --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] detecting rake db:migrate ?
Hi group, I have a line of code in environment.rb that cannot be run during a rake db:migrate, as it depends on some tables being present. I need to find a way to enclose this line in a check for db:migrate. I know how to check if we're in a rake task with: unless defined?(Rake) # do stuff, but skip when run from rake tasks end How can I take this further to make check if I'm running the rake db:migrate task? Thanks, -H --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: We don't need no stinking Badges! Guidance, anyone?
Why do you even need a UserBadge model? I would have User model, a Badge model, where the relationship is User belongs_to :badge, and badge has_many :users. Then you can simply assign it with some_user.badge = some_badge. It seems like you're adding complexity with the UserBadge model and the current attribute. Maybe I'm missing something but looks like, from the requirements you've outlined, you can drop that model altogether, and keep your design simple... -H On Feb 4, 2:37 pm, Lake Denman wrote: > Hi, Thanks for taking a look at this. I am in need of some guidance for > a particular problem: > > My Requirements: > The concept of a user > The concept of a badge > > A badge is simply a small image over the user's avatar that displays > extra information about the user. > An admin user will be able to assign a badge to any user and the > assigned badge will become the user's current badge, displayed for all > the world to see. > > Not required for now but required in the future: a user will be able to > choose from a list of badges and create their own custom badges. > > The Way of the Lost: > > After toying with these requirements and bits of code for a few days, I > have decided to ask for help. > Please enlighten me on a better, a more rails way of implementing this. > I am truly curious to know. There MUST be a better way! > > RELATIONSHIPS: > > I decided to implement the requirements by using a HasManyThrough > association. > I have three classes that collaborate: User, Badge, UserBadge > > class User < ActiveRecord::Base > has_many :user_badges > has_many :badges, :through => :user_badges > has_one :current_badge, :class_name => "UserBadge", :conditions => > { :current => true } > end > > class Badge < ActiveRecord::Base > # t.string :title > # t.string :image_file_name > # t.string :image_content_type > # t.integer :image_file_size > # t.datetime :image_updated_at > # t.timestamps > > has_many :user_badges > has_many :users, :through => :user_badges > end > > class UserBadge < ActiveRecord::Base > > # t.integer :user_id > # t.integer :badge_id > # t.boolean :current, :default => false > # t.timestamps > > belongs_to :user > belongs_to :badge > end > > ASSIGNING A CURRENT BADGE: > > I need a way to assign a badge to a user, so I created an attr_accessor > in the User class called :assign_current_badge > Then, I override the assign_current_badge setter method. > > The assign_current_badge=(badge_id) method: > * accepts a badge_id as a formal parameter > * updates any other current user_badges to "current=false" with the > deactivate_badges method > * checks for existance of a user_badge with the user's id and badge_id > * setting the user_badge.current to true if it exists > * creating and setting the user_badge.current to true if it does not > exist > * sets the user's current_badge_id to the badge_id > > class User < ActiveRecord::Base > ... # relationships > > attr_accessor :assign_current_badge > > def assign_current_badge=(badge_id) > deactivate_badges > if UserBadge.exists?(:user_id => id, :badge_id => badge_id) > user_badges.find_by_badge_id(badge_id).update_attribute(:current, > true) > else > user_badges.create!(:badge => Badge.find(badge_id), :current => > true) > end > self.current_badge_id = badge_id > end > > def deactivate_badges > user_badges.update_all("current = 0") > end > end > > PROBLEMS I HAVE ENCOUNTERED: > > The main problem I encounter is setting the current badge to a blank > value through the user's edit form. > "Couldn't find Badge with ID=" is being raised since there really is > no badge with a blank id. > This tells me, obviously, that there is a better way to go about this. > My gut tells me there is something shady about passing in the badge_id > instead of an existing badge object. > > - form_for @user, :url => admin_user_path(@user) do |f| > = f.error_message > # ... more fields > %div > = f.label :assign_current_badge > = f.select :assign_current_badge, Badge.all.map {|b| [b.title, > b.id]}, { :selected => @user.current_badge_id, :include_blank => true } > # ... submit button > > Finale: > If you have any advice for me, please reply. Hopefully I explained my > situation well enough through code and writing. If you would like me to > elaborate on anything, just ask. > -- > Posted viahttp://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--
[Rails] Re: ActiveRecord can validates "select" querys?
Completely agree with you, Mauricio. The only reason I can see the need to validate before a find is if your are absolutely obsessed with performance and you don't want to hit the DB if you know a priori that no record will be returned. This is definitely not a normal case. If the query takes too long you might have to rethink your schema, your query, or create proper indexes. On Mon, Feb 2, 2009 at 12:44 PM, Maurício Linhares < mauricio.linha...@gmail.com> wrote: > > Why do you need to validate on a find method? > > There should never be an invalid record at the database, that's why > there is no validation in a find and for the same reason there > shouldn't be. If you think you really need it, maybe you haven't > really figured out what your problem is. > > - > Maurício Linhares > http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en) > > > > On Mon, Feb 2, 2009 at 2:42 PM, Harold A. Giménez Ch. > wrote: > > In that case, I don't know of a way to reuse an ActiveRecord validation > > before running a find. You don't even have a ActiveRecord object at that > > point yet. > > > > You might just have to write your custom validations before running the > > find. Maybe someone else has a better option. Sorry :-o) > > > > -H > > > > On Mon, Feb 2, 2009 at 12:30 PM, Daniel López > > wrote: > >> > >> Harold A. Giménez Ch. wrote: > >> > Sounds like something you can do with ActiveRecord validations: > >> > > >> > > >> > > http://api.rubyonrails.org/classes/ActiveRecord/Validations/ClassMethods.html > >> > > >> > for example: > >> > > >> > validates_numericality_of :some_numer > >> > validates_length_of :something_else, :in => 3..12 > >> > > >> > You can use validate_format_of :a_date (and specify a regex), or > there's > >> > a > >> > plugin that helps for this (i haven't tried it: > >> > http://railslodge.com/plugins/111-validates-date-time) > >> > > >> > etc... > >> > > >> > is that what you're looking for? > >> > >> No... ActiveRecord validations only works if the SQL operation is an > >> insert or update ("create" and "update" methods, respectively), but I > >> also need it to select querys ("find" method). That's the problem... :S > >> > >> Thanks again! ;) > >> -- > >> Posted via http://www.ruby-forum.com/. > >> > >> > > > > > > > > > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: ActiveRecord can validates "select" querys?
In that case, I don't know of a way to reuse an ActiveRecord validation before running a find. You don't even have a ActiveRecord object at that point yet. You might just have to write your custom validations before running the find. Maybe someone else has a better option. Sorry :-o) -H On Mon, Feb 2, 2009 at 12:30 PM, Daniel López < rails-mailing-l...@andreas-s.net> wrote: > > Harold A. Giménez Ch. wrote: > > Sounds like something you can do with ActiveRecord validations: > > > > > http://api.rubyonrails.org/classes/ActiveRecord/Validations/ClassMethods.html > > > > for example: > > > > validates_numericality_of :some_numer > > validates_length_of :something_else, :in => 3..12 > > > > You can use validate_format_of :a_date (and specify a regex), or there's > > a > > plugin that helps for this (i haven't tried it: > > http://railslodge.com/plugins/111-validates-date-time) > > > > etc... > > > > is that what you're looking for? > > No... ActiveRecord validations only works if the SQL operation is an > insert or update ("create" and "update" methods, respectively), but I > also need it to select querys ("find" method). That's the problem... :S > > Thanks again! ;) > -- > Posted via http://www.ruby-forum.com/. > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: ActiveRecord can validates "select" querys?
Sounds like something you can do with ActiveRecord validations: http://api.rubyonrails.org/classes/ActiveRecord/Validations/ClassMethods.html for example: validates_numericality_of :some_numer validates_length_of :something_else, :in => 3..12 You can use validate_format_of :a_date (and specify a regex), or there's a plugin that helps for this (i haven't tried it: http://railslodge.com/plugins/111-validates-date-time) etc... is that what you're looking for? On Mon, Feb 2, 2009 at 12:10 PM, Daniel López < rails-mailing-l...@andreas-s.net> wrote: > > Harold wrote: > > Can you give an example of what you mean by "validate the data before > > passing it over to SQL"? > > > > If it's SQL injection you're worried about, rails can help clean up > > user input, but I'm not sure that's where your heading with this... > > > > > > > > On Feb 2, 11:18�am, Daniel L�pez > > SQL Injection, mmm... yes, maybe, but I refer particularly to check if a > string is numeric, date type or too short for the database values (for > example). > > Only if these requirements are OK, the select query is executed. > Otherwise, the application should return false or something. > > Thanks in advance, Harold. ;) > -- > Posted via http://www.ruby-forum.com/. > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: ActiveRecord can validates "select" querys?
Can you give an example of what you mean by "validate the data before passing it over to SQL"? If it's SQL injection you're worried about, rails can help clean up user input, but I'm not sure that's where your heading with this... On Feb 2, 11:18 am, Daniel López wrote: > I have an application that makes a render inline, and another in XML > based on data from an URL. > I need to validate the data before passing it over to SQL, and I would > like to receive the errors in the returned array, or at least a > TRUE/FALSE. As there is no associated view file I don’t know how to... > > Could someone help me out or orientate me in some way? > > Regards and thanks, > > Daniel. > -- > Posted viahttp://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Merging array with same key - HELP
Hi, hash = {} array1.uniq.each { |d| hash[d] = [] } array1.each_with_index { |x,i| hash[x] << array2[i] } hash.each_key { |key| hash[key] = hash[key].join('-') } hash.inspect # => {"01/01/2009"=>"1stjan1-1stjan2-1stjan3", "10/01/2009"=>"10thjan1-10thjan2"} Enjoy, -Harold On Jan 27, 2:13 am, Shankar Ganesh wrote: > Hi , > I need to merge an array in ruby on rails. > > array1 = > ['01/01/2009','01/01/2009','10/01/2009','01/01/2009','10/01/2009'] > array2 = ['1stjan1','1stjan2','10thjan1','1stjan3','10thjan2'] > > I need to have array like this > > array3 = > ['01/01/2009'=>'1stjan1-1stjan2-1stjan3','10/01/2009'=>'10thjan1-10thjan2'] > > Thanks in Advance. > -- > Posted viahttp://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Merging array with same key - HELP
Hi, hash = {} array1.uniq.each { |d| hash[d] = [] } array1.each_with_index { |x,i| hash[x] << array2[i] } hash.each_key { |key| hash[key] = hash[key].join('-') } hash.inspect # => {"01/01/2009"=>"1stjan1-1stjan2-1stjan3", "10/01/2009"=>"10thjan1-10thjan2"} Enjoy, -Harold On Jan 27, 2:13 am, Shankar Ganesh wrote: > Hi , > I need to merge an array in ruby on rails. > > array1 = > ['01/01/2009','01/01/2009','10/01/2009','01/01/2009','10/01/2009'] > array2 = ['1stjan1','1stjan2','10thjan1','1stjan3','10thjan2'] > > I need to have array like this > > array3 = > ['01/01/2009'=>'1stjan1-1stjan2-1stjan3','10/01/2009'=>'10thjan1-10thjan2'] > > Thanks in Advance. > -- > Posted viahttp://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Ruby on Rails Dates
Can't you just send out an email, with [JOBS] in the subject? I don't think anyone would be bothered by that. Don't change a discussion subjects just for spite. Have some class. On Jan 14, 11:13 am, Michael Michael wrote: > I don't mean to be too intrusive as I am a dreadful IT Recruiter that > you probably all despise. I am working on filling a number of RoR > Developer positions for an exciting young company in NYC. If you are > interested in learning more about the position please e-mail me, > mmart...@apexsystemsinc.com or call me at 212.991.1835. No one has to > know that you contacted me regarding and you can still bash me here in > the blog. > > Have a great day! Thanks! > > > > Rob Pa wrote: > > Hi, > > > I am using a MySQL database and have a row callsed date in my fixtures > > table. I am wanting to display fixtures coming up, i.e. ahead of todays > > date. > > > In my controller I am thinking of doing; > > @fixtures = Fixtures.find(:all, :conditions => "date > #{Date.today} ", > > :order => "id DESC") > > > Do dates work this way, is this the correct way to go about it? > > > Also, are there any forum systems built with Ruby on Rails that I can > > download for use on my site? > > > Thanks in advance, Rob > > -- > Posted viahttp://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: named_scope on has_many, find all records that don't have elements in that association
Thinking in SQL, you want to do this: select * from customers left outer join addresses on customers.address_id = addresses.id where addresses.id is null. First thing that comes to mind here something like: Customer.find(:all, :include => :address, :conditions => 'addresses.id is null') hope that helps, -H On Jan 11, 5:32 pm, Gabriele Tassoni wrote: > Hi, > I have a Customer model that has_many :addresses, is there a way (via > named scope or any other method that's ... ehm ... model side) to > obtain all the Customers that don't have any addresses at all (for > which the associated array would be empty)? > > Thank you for the answer... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: How to pass parameters to a script in "lib" from termina
Well, you have to play nice with the "rules" of the command line (like no spaces etc). Also note that whatever comes into your rake task is simply a string. You would have to parse that string and build any object you need, such as a hash or array... Any code on how you're handling the params? On Fri, Jan 9, 2009 at 4:21 PM, Joe Peck wrote: > > I've put it in a raketask, works now, except for one thing; if I try to > pass a hash to it as a parameter, it seems like it just stops. Hmm... > -- > Posted via http://www.ruby-forum.com/. > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: How to pass parameters to a script in "lib" from terminal
I don't think you can do it using script/runner (I may be wrong). You could run the script directly using ruby lib/joe_converter.rb, and handle the parameters in your script. Your rails app wouldn't load in this case. Another (probably preferred) option is to create a rake task in lib/tasks that takes the parameters and calls JoeConverter.do_the_conversion passing the parameters. If you are accessing any other classes/modules of your rails app (like any model for instance), go with the rake task as they would load as well. Someone else might have better ideas though ;) On Jan 9, 3:49 pm, Joe Peck wrote: > Hi, > > This should be easy, for some reason I can't remember how to do it. > > I have in /lib a file called "joe_converter.rb" that I want to be able > to run from terminal. Here's the beginning of "joe_converter.rb": > ** > require 'active_record' > > # Takes in a URL, creates all needed objects, and ends up creating an > LqSnapshot for that URL > class JoeConverter > def self.do_the_conversion url, scores, user_id > ** > > How can I run this from terminal correctly? I tried with > "script/runner", and put in the necessary parameters, but I get back > this: > > wrong number of arguments (0 for 5) (ArgumentError) > > Anyone have any ideas about this? > -- > Posted viahttp://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Additional config file like database.yml
You can do solr_conf = open('path/to/solr.yml', 'r') { |f| YAML.load(f) } solr_conf now holds a hash with your parameteres. You can access it simply by doing something like: url = solr_conf[RAILS_ENV][:url] On Jan 9, 11:33 am, scott wrote: > you could code it yourself, i think there is a railscast that shows an > easy way to do it. or you could use one of the many plugins or gems > out there. i just recently > usedhttp://github.com/binarylogic/settingslogic/tree/master > > On Jan 9, 9:32 am, Peter Hickman wrote: > > > I have a web site that accesses Solr (a Lucene based search engine > > accessed via REST). I would like the configuration to be handled in > > the same was as database.yml. I envision a file called solr.yml that > > looks something like this in the config directory: > > > development: > > url:http://dev.solr.example.com/search > > > test: > > url:http://test.solr.example.com/search > > > production: > > url:http://production.solr.example.com/search > > > If I was to write this file how would I access it? > > > Any pointers would be appreciated as it would aid testing and I have a > > couple of other projects that could use this technique. > > > Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Trying to sort results of one-to-many relationship find
This is a plain association, no join table involved. Try this in script/console and see if it solves your problem. The DB can easily take care of the sorting: orders = Order.find(:all, :conditions => '...', :include => :payee, :order => 'payees.last_name') Then, orders.each { |o| puts o.payee.last_name } -H On Jan 8, 11:10 am, Corey Murphy wrote: > Assuming I have two models: > > Order "belongs_to :payee" > Payee "has_many :orders" > > In the orders table, I store the payee_id. > > If I want to pull all orders and display the list alphabetically by the > payees last name, what would be the best way to do it? > > Would I need to setup a true "join" table and then run my find on it? I > can't do this through the view using a sort plugin since that simply > changes the finders SQL and doesn't include the association logic needed > here. > > Since I'm accessing the payee's name through the association > "order.payee.last_name" what is the best way to accomplish what I need > or do I need to write some convoluted method that breaks down the > recordset and orders it manually? > -- > Posted viahttp://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: 126: The specified module could not be found. - c:/ruby/lib/ruby/gems/1.8/gems/ruby-postgres-0.7.1.2006.04.06-x86-msw in32/postgres.so
Is the postgres bin directory in your PATH? Usually: C:\Program Files\PostgreSQL\8.3\bin On Jan 7, 4:07 pm, Ruby Newbie wrote: > I have install postgres but I am getting this message when I am > starting the application. Please help --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: how to monkeypatch Hash's []= method
I was focusing on the "=" being the problem... Worked nicely. Many thanks! On Tue, Jan 6, 2009 at 7:20 PM, Frederick Cheung wrote: > > > On 6 Jan 2009, at 23:56, Harold A. Giménez Ch. wrote: > > > Thanks for the response. > > > > So how in the world is this implemented? The []= method's source > > code is in C. Other classes override it in a subclass, which works > > fine, but how would I go about implementing a method that works like > > the Hash class' []= method? > > > > I'm not sure what you mean by "skipping alias_method_chain" this > > time. If I do > > > > alias :[]_without_feature=, :[]= > > alias :[]=, :[]_with_feature > > > > I get the same error, as expected. So how would I go about changing > > this method's behavior? > > > > just call it square_bracket_without feature or something like that. > the problem isn;t the method aliasing it's defining a method called > []_with_feature= > > Fred > > > Thanks again, > > -H > > > > On Tue, Jan 6, 2009 at 6:49 PM, Frederick Cheung < > frederick.che...@gmail.com > > > wrote: > > > > > > On 6 Jan 2009, at 23:36, Harold wrote: > > > > > > > > I'm trying to monkeypatch the []= method in the Hash class: > > > > > > > doesn't seem to be anything to do with alias_method_chain - just > > sticking > > def []_with_feature=(a,b) > > puts 'foo' > > end > > > > into irb causes similar errors. You'll just have to skip alias method > > chain this time. > > > > Fred > > > Hash.class_eval do > > > def []_with_feature=(a,b) > > >puts 'foo' > > > end > > > alias_method_chain :[]=, :feature > > > end > > > > > > Something is wrong with the syntax, but I can't figure out what. The > > > alias_method_chain method does look for punctuation (= in this case) > > > and expects it to be at the end of the aliased method ([] > > > _with_feature=), but I get the following syntax error: > > > > > > SyntaxError: compile error > > > (irb):5: syntax error, unexpected ')', expecting '=' > > > (irb):7: syntax error, unexpected kEND, expecting ')' > > > (irb):9: syntax error, unexpected kEND, expecting ')' > > > > > > Any ideas? > > > > > > Thanks, > > > -H > > > > > > > > > > > > > > > > > > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: how to monkeypatch Hash's []= method
Thanks for the response. So how in the world is this implemented? The []= method's source code is in C. Other classes override it in a subclass, which works fine, but how would I go about implementing a method that works like the Hash class' []= method? I'm not sure what you mean by "skipping alias_method_chain" this time. If I do alias :[]_without_feature=, :[]= alias :[]=, :[]_with_feature I get the same error, as expected. So how would I go about changing this method's behavior? Thanks again, -H On Tue, Jan 6, 2009 at 6:49 PM, Frederick Cheung wrote: > > > On 6 Jan 2009, at 23:36, Harold wrote: > > > > > I'm trying to monkeypatch the []= method in the Hash class: > > > > doesn't seem to be anything to do with alias_method_chain - just > sticking > def []_with_feature=(a,b) > puts 'foo' > end > > into irb causes similar errors. You'll just have to skip alias method > chain this time. > > Fred > > Hash.class_eval do > > def []_with_feature=(a,b) > >puts 'foo' > > end > > alias_method_chain :[]=, :feature > > end > > > > Something is wrong with the syntax, but I can't figure out what. The > > alias_method_chain method does look for punctuation (= in this case) > > and expects it to be at the end of the aliased method ([] > > _with_feature=), but I get the following syntax error: > > > > SyntaxError: compile error > > (irb):5: syntax error, unexpected ')', expecting '=' > > (irb):7: syntax error, unexpected kEND, expecting ')' > > (irb):9: syntax error, unexpected kEND, expecting ')' > > > > Any ideas? > > > > Thanks, > > -H > > > > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] how to monkeypatch Hash's []= method
I'm trying to monkeypatch the []= method in the Hash class: Hash.class_eval do def []_with_feature=(a,b) puts 'foo' end alias_method_chain :[]=, :feature end Something is wrong with the syntax, but I can't figure out what. The alias_method_chain method does look for punctuation (= in this case) and expects it to be at the end of the aliased method ([] _with_feature=), but I get the following syntax error: SyntaxError: compile error (irb):5: syntax error, unexpected ')', expecting '=' (irb):7: syntax error, unexpected kEND, expecting ')' (irb):9: syntax error, unexpected kEND, expecting ')' Any ideas? Thanks, -H --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: AR deep clone
Ran into this a while back. your_ar_instance.dup will keep the child records as well. On Jan 6, 1:25 pm, Michael Rigart wrote: > Hi all, > > I'm having problems with cloning an ActiveRecord Object. The object > consists of multiple child objects, so when I use the normal clone > method, it only clones the attributes of the parent object. > > Could someone help me out telling me how I can clone the child objects > as wel? I have tried like: > > tmp.my_items.each do |item| > @clone.my_items.build(item.clone) > end > > but that didn't help. I know it must be something fairly easy, but I > can't figure it out. > > Thank you in advance for the help. > -- > Posted viahttp://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: items.destroy doesn't work
How about Item.destroy_all(conditions) Which will call the destroy callback methods (slow if you are destroying many records). If you don't care about callbacks, use delete_all instead. http://api.rubyonrails.org/classes/ActiveRecord/Base.html#M001974 On Jan 6, 3:22 pm, scott wrote: > why doesn't this work > items.destroy if items = find(:all, :conditions => ...) > > right now i have this that works, but it seems ugly and inefficient. > > if items = find(:all, :conditions => ...) > items.each do |item| > item.destroy > end > end > > there must be a better way --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Cloning ActiveRecord objects
Try your_active_record_instance.dup instead of .clone. On Jan 6, 6:43 am, Rob Lacey wrote: > Hi there, > > I've been working on a solution to try and fix a problem I am getting > with the Interlock plugin. However, my quick solution was to clone my > ActiveRecord object and store the clone. I now realise that cloning > ActiveRecord objects merely extracts the attributes and creates a new > object with the same attributes. What I want is to clone the whole > object, in this case assocations aren't necessary just the object with > the correct id. > > Is there any reason why this would be bad? I guess cloning the object is > generally used to duplicate records but here I want to take the object > and cache it without affecting the original object. > > RobL --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Using both :include and :joins in find()
It would be nice to know what error gets thrown. I suspect it has something to do with using :select in a find where you also use :include, but I may be wrong. As far as I know, :select is ignored when you used :include. Another potential error is that you're joining the users table twice: once on the :include (a left outer join), and once with the :joins (an inner join). The generated SQL would not contain aliases for the joined table, so it is specifying users twice. Is it your DBMS throwing the error? >From the look of your :select, it seems like what you want back is User objects, not Greeter objects. If so, why are you querying using "Greeter.find", instead of "User.find"? This could probably be what you're looking for: User.all(:joins => :greeter, :order => 'users.nickname') #get all users who also are greeters. or Greeter.all(:include => :users, :order => 'users.nickname') #get all greeters, and eager load the users. What is it? No idea! HTH, -H On Dec 22, 5:43 pm, "John Kopanas" wrote: > I would like to do this: > > Greeter.find(:all, :select => "DISTINCT user_id", :include => [:user], > :joins => [:user], :order => "users.nickname") > > But an error is always thrown, I either do the join so that I go > order on the join table... which I have to do... or I do eager loading > which helps out a lot with the efficiency of the page load time... but > I can not do both it seems... or can I? > > -- > John Kopanas > j...@kopanas.com > > Blog:http://www.kopanas.com > Conference:http://www.cusec.net > Twits:http://www.twitter.com/kopanas --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Help creating and using database
I think what you're looking for is the build method, something along the lines of @job.steps.build in your controller. Take a look at the complex form railscasts by Ryan Bates: http://railscasts.com/episodes/73-complex-forms-part-1 (go to parts 2 and 3 after you're done with part 1). On Dec 22, 5:56 am, John Smith wrote: > Thanks a lot, but I think that does not solve my problem, because I need > to create a job to make a relation between the job and it steps. With > that, I can create steps without a job, but how can I make relation > between these steps and the job. Should I have to take the last steps > and make a relation with the job I am creating? I think this is a bas > solution. > Any other ideas? > -- > Posted viahttp://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: RoR IDE
I second vim with rails.vim, and a few other plugins: matchit camelcasemotion fuzzyfinder and fuzzyfind_textmate snippetsEmu vcscommand and either vividchalk or railscasts as a colorscheme. Vim is definitely worth the learning curve, but you need to invest some time before you realize how effective it is. I couldn't go back to anything else at this point... On Dec 21, 1:20 am, Near Cruise wrote: > Cai Yin wrote: > > I use RoRED on Windows It it nice > > > On Sat, Dec 20, 2008 at 11:38 PM, Schalk Neethling > > > Netbean 6.5 has strong power in rails coding. > You can try it free. > > It can automaticly generate code to help building structure. > -- > Posted viahttp://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: SuperInPlaceControl
You are absolutely right, it's just JavaScript, and digging under the hood uncovered my error. I also modified the plugin slightly to accept a :url parameter in order to specify a controller, action, etc. Just more flexible. Thanks, -H On Fri, Dec 5, 2008 at 4:42 PM, Hassan Schroeder <[EMAIL PROTECTED] > wrote: > > On Fri, Dec 5, 2008 at 12:51 PM, Harold <[EMAIL PROTECTED]> wrote: > > > The fact that I get no response tells me that nobody is using > > SuperInPlaceControls. What's out there for in place select editing on > > Rails 2.1? Any pointers or comments welcome. > > I think if you had a reproducible test case, it wouldn't be that hard > to get some help fixing the problem -- it's just JavaScript :-) > > >> In Rails 2.1, I am using theSuperInPlaceControlplugin to render an > >> in_place_select on an instance of a model with a has_many > >> relationship. So far so good, except that when I click on OK to save > >> the user's selection, the ajax call is posted, the record is updated, > >> but the label on the view never gets updated. In fact, it blanks out. > > Sounds to me like it might be getting updated with an empty value... > > FWIW, > -- > Hassan Schroeder [EMAIL PROTECTED] > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: SuperInPlaceControl
Bump... The fact that I get no response tells me that nobody is using SuperInPlaceControls. What's out there for in place select editing on Rails 2.1? Any pointers or comments welcome. Thanks. On Dec 5, 12:50 am, Harold <[EMAIL PROTECTED]> wrote: > In Rails 2.1, I am using theSuperInPlaceControlplugin to render an > in_place_select on an instance of a model with a has_many > relationship. So far so good, except that when I click on OK to save > the user's selection, the ajax call is posted, the record is updated, > but the label on the view never gets updated. In fact, it blanks out. > > I am using render :text in the controller method, and Firebug reports > the text being returned to the client after the ajax call. > > Any idea why the label does not update? I would be happy with simply > looking at some example demo, post, etc. > > Thanks, > -H --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] SuperInPlaceControl
In Rails 2.1, I am using the SuperInPlaceControl plugin to render an in_place_select on an instance of a model with a has_many relationship. So far so good, except that when I click on OK to save the user's selection, the ajax call is posted, the record is updated, but the label on the view never gets updated. In fact, it blanks out. I am using render :text in the controller method, and Firebug reports the text being returned to the client after the ajax call. Any idea why the label does not update? I would be happy with simply looking at some example demo, post, etc. Thanks, -H --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Iterate through a table record
A legs table seems more flexible, however: <% (1..36).each do |p| %> Leg <%= @race.send(('leg' + p).to_sym) %> <% end %> On Nov 21, 5:59 pm, Bill McGuire <[EMAIL PROTECTED]> wrote: > Lennart Koopmann wrote: > > 2008/11/21 Bill Mcguire <[EMAIL PROTECTED]> > > >> Is there a way to increment @race.leg so I don't have to write > >> @race.leg1 [EMAIL PROTECTED] ? > > > Can you change the database structure? I think it would make more sense > > to > > have a "legs" table in this case. Then you could lookup all legs of a > > given > > race and iterate through them with @legs.each > > > So long > > Lennart Koopmann > > Lennart...interesting thought, problem is I'll still have the default > fields I have to deal with (created_at,updated_at, race_id)so it > wouldn't be a purely 'leg' table. I could filter that out I guess but I > want to try to make this work. > Thanks for the reply > -- > Posted viahttp://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Distinct selection
Agreed with James that we don't have much info on what you are trying to achieve. Why can't you just query the roles table directly? Anyways, you can always uniq the array: http://www.ruby-doc.org/core/classes/Array.html#M002237 On Nov 21, 1:25 pm, "James Mitchell" <[EMAIL PROTECTED]> wrote: > Ok, maybe we misunderstood each other. > > If you want a list of roles, why would you go through the members > table to get it? You can just do Roles.find(:all).map(&:name) > > I'm not sure what you doing with "assignable?". It seems to be > important to you, but you have not explained what it is supposed to > return. > > What does it do? Does it return: > a) members who do not have a role and are therefore able to be > assigned a role ? > b) some awkward pass-through delegation to roles that aren't assigned yet ? > > -- > James Mitchell > > On Fri, Nov 21, 2008 at 9:51 AM, Yan Oleg > > <[EMAIL PROTECTED]> wrote: > > > James Mitchell wrote: > >> What exactly are you trying to do? > > >> From reading what you wrote, it sounds like you want a list of roles > >> that have not already been assigned. Is that right? > > >> -- > >> James Mitchell > > >> On Fri, Nov 21, 2008 at 8:59 AM, Yan Oleg > > > NO, it isn't right. > > > If I use this code: > > > members.select {|m| m.role.assignable?}.collect {|m| m.role}.sort > > > ...I get several roles with the same ID and NAME, but I want to get > > unique ones, like using DISTINCT operation in SQL statements (SELECT > > DISTINCT name FROM roles.) > > > But unfortunately I can get the list from table "members", where records > > may have several same role names: > > > Manager > > Tester > > Manager > > Manager > > Manager > > Tester > > Developer > > Developer > > Tester > > Developer > > Tester > > Developer > > Developer > > Developer > > > But I have to get this list: > > > Manager > > Tester > > Developer > > -- > > Posted viahttp://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Where should data migrations go?
I do "data only" migrations all the time, especially for reference values and such. What kind of problems do you encounter? The one caveat could be that you may have to define the model classes involved inside your migration. For example: class Software < ActiveRecord::Base; end and in your self.up, simply use it as you would normally, ie: Software.find_all_by_name(['foo','bar']).each do |s| # do some updates and saves with s end hope that helps. -H On Nov 14, 5:22 pm, "Anthony Ettinger" <[EMAIL PROTECTED]> wrote: > I recall problems with putting data migrations directly into a > database migration file. > Where should I do them? > > I need to run a few SQL queries on the database, and then delete a few > unnecessary things. > Something like this pseudo example: > > #get ids of old softwares > old_ids = SELECT id FROM softwares WHERE name IN ('foo', 'bar'); > good_id = SELECT id FROM softwares WHERE name = 'Good'; > > #get directories using old softwares > SELECT id, software_id FROM directories WHERE software_id IN > (old_ids.join(',')); > > #update these directories with new software > UPDATE directories SET software_id = good_id WHERE software_id IN > (old_ids.join(',')); > > #delete old softwares > DELETE from softwares WHERE id IN (old_ids.join(',')); > > There is no change to the database schema itself, should this be a > throw-away rake task or is can it be done as a "DATA ONLY" migration? > > -- > Anthony Ettinger > 408-656-2473http://anthony.ettinger.name --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: database documentation
Along the same lines as Fred suggests, it should be on the model. We've been using the annotate_models to do it for us. http://agilewebdevelopment.com/plugins/annotate_models -H On Nov 7, 5:17 am, Frederick Cheung <[EMAIL PROTECTED]> wrote: > On 7 Nov 2008, at 01:30, Norm wrote: > > > > > Fernando wrote: > >> so far i havent been able to find a way to document my database with > >> rails. > >> is this a flaw? a feature? a hidden feature? or they just dont care > >> about documenting the database? > > You could just put comments in your migrations. They are ruby code. > > That's not that great, for example a table's structure can be the > accretion of multiple migrations. > The rails way is probably just to keep that sort of stuff in the > appropriate model (and since the rails way is not to use things like > triggers and what not, the model encapsulates pretty much all the > intelligence in the app). > > Fred > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: 2 apps with 1 one database.
Well, to me it sounds like your "admin app" is just a bunch of rake tasks that do some bookkeeping for you. You seem to be solving a problem that does not exist - again, what's the problem with the admin code living in the same app? Even if it makes it to production? Be that as it may, if you insist in having two rails apps, I would disable the db:migrate rake task on the admin app. Make it raise an exception. Same with the migration generator. On Oct 31, 6:56 am, jef <[EMAIL PROTECTED]> wrote: > > Like I said, it doesn't matter which app you run your migrations from. Just > > pick one. > > My admin app will never be in production. > It's just a place where I store one shot code (parsing website code, > etc ...). --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: 2 apps with 1 one database.
On the other hand, I don't understand why not use role based authorization to the admin area? On Oct 30, 4:54 pm, jef <[EMAIL PROTECTED]> wrote: > > Interesting. What leads you to want to separate the admin functionality > > into a completely separate app? > > I want my dev app to be equal to the production app to make > deployement easier. > > > The easiest way I can think of would be to simply run all your migrations > > from one of the apps. As long as you never run any migrations from the > > second app I can't think of any way you'd run into conflicts. Doesn't mean > > you won't. Just that I can't think of any off the top of my head ;-) > > I need to run migrations from the admin app. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Database optimization approach
Agree with Erol. Leave the schema as it is, and use proper DB indexes to help with performance. It is posts that belong to groups, not comments. Right? On Sep 26, 1:24 pm, Erol Fornoles <[EMAIL PROTECTED]> wrote: > On Sep 27, 12:47 am, elioncho <[EMAIL PROTECTED]> wrote: > > > Hello everyone, > > > I'll like to hear your opinion on the following issue. I have a posts > > and post_comments table. Posts belong to a group, so there is a > > group_id column on it. I want to query for all the post_comments of a > > user for a specific group, so what I am doing now is a INNER JOIN > > between the two tables. My question is: Is it better to have a > > group_id column on the post_comments table for optimize search or > > that's redundant? > > > Thanks, > > > Elioncho > > Better that you keep your data struct as is, IMHO. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---