I''m trying to run some non-ruby code in my rails app and i''m not sure how to do this. The code i have would take a really long time to port to ruby and so i''d rather run it as is (its php). What i would like to have happen is that the code can be invoked as an ajax call. And just return some data in JSON. I keep running into a routing failure by actioncontroller and i''m not sure how to get around this. I know its seems terrible to run php inside the rails app, but i''m not sure what the best solution is here. I''d greatly like some insight on the best way to accomplish. thanks in advance.
On Mon, Aug 07, 2006 at 09:35:08PM -0700, Manish Shah wrote:> I''m trying to run some non-ruby code in my rails app and i''m not sure > how to do this. The code i have would take a really long time to port > to ruby and so i''d rather run it as is (its php). What i would like > to have happen is that the code can be invoked as an ajax call. And > just return some data in JSON. > > I keep running into a routing failure by actioncontroller and i''m not > sure how to get around this.This way of working (mixing Rails and legacy code) is quite reasonable, and does work (I know, I have a pretty massive app which is slowly being Railsed from a base of Large, Hideous PHP). If you told us more about what you''re trying to accomplish and what routing errors you''re getting, I''d imagine that your problem will quickly be pointed out and solved. - Matt
2006/8/8, Manish Shah <mnshah@gmail.com>:> > I know its seems terrible to run php inside the rails app, but i''m not > sure what the best solution is here. I''d greatly like some insight on > the best way to accomplish.why? i think its completely ok to do so. its ruby its rails. you CAN port it to rails,, but if you dont want to, you CAN do it another way. i think that sentence was in one of the railsconf keynotes... and i like it. -- Michael Siebert <info@siebert-wd.de> www.stellar-legends.de - Weltraum-Browsergame im Alpha-Stadium -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060808/0b1d3e54/attachment.html
Here is the routing error i''m getting: ActionController::RoutingError (Recognition failed for "/myscript.php"): /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/routing.rb:521:in `recognition_failed'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/routing.rb:511:in `recognize!'' /usr/local/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/dispatcher.rb:38:in `dispatch'' I''m trying to figure out how to route this request to myscript.php. Is the right place to do it in .htaccess or should something be done in httpd.conf? Eventually i''ll port the php to ruby, but time is limited right now and i just need to get something working. Thanks. Michael Siebert wrote:> 2006/8/8, Manish Shah <mnshah@gmail.com>: >> >> I know its seems terrible to run php inside the rails app, but i''m not >> sure what the best solution is here. I''d greatly like some insight on >> the best way to accomplish. > > > why? i think its completely ok to do so. its ruby its rails. you CAN > port it > to rails,, but if you dont want to, you CAN do it another way. i think > that > sentence was in one of the railsconf keynotes... and i like it. > > -- > Michael Siebert <info@siebert-wd.de> > > www.stellar-legends.de - Weltraum-Browsergame im Alpha-Stadium-- Posted via http://www.ruby-forum.com/.
You need to set up apache to handle PHP requests. That would be done in httpd.conf On 8/8/06, Manish Shah <mnshah@gmail.com> wrote:> Here is the routing error i''m getting: > > ActionController::RoutingError (Recognition failed for "/myscript.php"): > /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/routing.rb:521:in > `recognition_failed'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/routing.rb:511:in > `recognize!'' > /usr/local/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/dispatcher.rb:38:in > `dispatch'' > > > I''m trying to figure out how to route this request to myscript.php. Is > the right place to do it in .htaccess or should something be done in > httpd.conf? > > Eventually i''ll port the php to ruby, but time is limited right now and > i just need to get something working. > > Thanks. > > Michael Siebert wrote: > > 2006/8/8, Manish Shah <mnshah@gmail.com>: > >> > >> I know its seems terrible to run php inside the rails app, but i''m not > >> sure what the best solution is here. I''d greatly like some insight on > >> the best way to accomplish. > > > > > > why? i think its completely ok to do so. its ruby its rails. you CAN > > port it > > to rails,, but if you dont want to, you CAN do it another way. i think > > that > > sentence was in one of the railsconf keynotes... and i like it. > > > > -- > > Michael Siebert <info@siebert-wd.de> > > > > www.stellar-legends.de - Weltraum-Browsergame im Alpha-Stadium > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
On 8/8/06, Manish Shah <mnshah@gmail.com> wrote:> Here is the routing error i''m getting: > > ActionController::RoutingError (Recognition failed for "/myscript.php"): > /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/routing.rb:521:in > `recognition_failed'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/routing.rb:511:in > `recognize!'' > /usr/local/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/dispatcher.rb:38:in > `dispatch'' > > > I''m trying to figure out how to route this request to myscript.php. Is > the right place to do it in .htaccess or should something be done in > httpd.conf?The exact answer depends on what how you are running rails and php. The simplest solution is probably just to run apache/php on the same hostname but a different port. But if apache is already out in front of your rails app somewhere, you could just use a simple Alias command or something similar. The solution is fairly simple, but depends on your exact setup.
Manish: On 08/08/06, Manish Shah <mnshah@gmail.com> wrote:> ActionController::RoutingError (Recognition failed for "/myscript.php"): > /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3 > /lib/action_controller/routing.rb:521:in > `recognition_failed'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.3 > /lib/action_controller/routing.rb:511:in > `recognize!'' > /usr/local/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/dispatcher.rb:38:in > `dispatch'' > > I''m trying to figure out how to route this request to myscript.php. Is > the right place to do it in .htaccess or should something be done in > httpd.conf? >Try using absolute paths with all redirects. -- Cheers, Hasan Diwan <hasan.diwan@gmail.com> -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060809/01b8e7b5/attachment.html
Hi, I also have a need to run PHP inside my ROR scripts. I want to execute the code directly in the views though. So far I''ve tried putting <?php echo ''test''; ?> right inside the index.rhtml file. After checking the source code of the rendered page it just shows "<?php echo ''test''; ?>". I''ve tested my servers by running a test.php file in /public and that executes fine. Does anyone know how to execute PHP inside of the rhtml view? Thanks, Nate -- Posted via http://www.ruby-forum.com/.
Nate wrote:> Hi, > > I also have a need to run PHP inside my ROR scripts. I want to execute > the code directly in the views though. So far I''ve tried putting <?php > echo ''test''; ?> right inside the index.rhtml file. After checking the > source code of the rendered page it just shows "<?php echo ''test''; ?>". >If you''re serving the app on a mongrel through a proxy to apache/whatever, you may be able to have apache run php over it. Or, write a proxy _in_ php and have it eval everything it gets back! If it''s a long process non-inline thing, I''d toss files into a queue to be run by cron. -- Matthew Beale :: mixonic@synitech.com Resume & Portfolio @ http://madhatted.com -- Posted via http://www.ruby-forum.com/.