![]() |
| ||
| My first Ruby programming question :-) Hello, I'm pleased to be here by way of the html forum. I've been using php for static pages for 18 months. I wanted to learn rails, but I just realized that I could configure my host to automate index.rhtml files just like php. This is a major motivator for me to learn Ruby, and after a few more months I can start fresh with Rails. OK, here is the code that works in PHP, and what I've got so far in Ruby. The JS effect can be viewed here: http://listenlight.net/13 --- <?php <% In the Ruby example, I've set the visibility attribute in the CSS, attempting to clean the markup. Also, is there a way to do a parallel incrementing?--such as a, b += 1, 1 (?) |
| ||
| Re: My first Ruby programming question :-) My solution --- <%= No more PHP for this one. |
| ||
| Re: My first Ruby programming question :-) Quote:
Although your solution is fine it can be a little more readable (and re-usable) in rails. In the controller: def banner(text) Then in the view <%= banner("listenlightpoetryjournal") %> |
| ||
| Re: My first Ruby programming question :-) pty's improvement is a good one! The only nit I have with it is that I wouldn't put the bannermethod in the controller, since it has nothing to do with the "traffic cop" jobs that controllers normally do. I would put it in a helper file, either this controller's helper file or the application_helper.rbfile (if it's a method you'd want to use in other controllers). Ed |
| ||
| Re: My first Ruby programming question :-) thanks. i appreciate the direction on working with strings, but it's only for static pages. i'm not using the rails framework. i just wanted to make it concise. |
| ||
| Re: My first Ruby programming question :-) Quote:
Thanks Ed :) |
| All times are GMT -4. The time now is 3:51 pm. |
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC