Showing posts with label Learning Ruby. Show all posts
Showing posts with label Learning Ruby. Show all posts

Monday, July 6, 2009

Workshop 5/6: More Taxi booking system - followup

Must give thanks to Karen's comment. Even though what she said to do was what I had done, the fact that she commented actually triggered the correct outcome for me.

I have got the BookCab form integrated with my OTBS. In order to do this I had to do the following

  1. Move the bookcab method into the VehicleController
  2. Move the bookcab.html.erb file into the views\vehicle\ directory
  3. Change the form action to form_action ="cabtype" instead of "vehicle/cabtype"
  4. modify my application.html.erb file so that the 'Book Cab' link pointed to the correct controller and action.

On the face of it it looks like the variable scope is confined to the MVC that is of interest. In this case it was the cab booking variables in the bookcab view being transferred to the cabtype view.

My next step now is to introduce a login mechanism and enable passenger information to be collected.

Sunday, July 5, 2009

Workshop 5/6: More Taxi booking system

I have just been having a lot of fun.

I thought I would go back into the Taxi Booking system, to improve the look of the site and to look at adding login functionality. This would involve utilising what we had developed in workshop 4 with the changes in workshop 5.

I also wanted to change how I had dealt with the protect_from_forgery error that we all got in workshop 5. I simply hashed out the line, and so everything worked.

Well the idea started out as a good one. Unfortunately, I managed to break everything, so that nothing worked. I changed the routes file so that there were no recognised routes.

Scratching my head for half an hour ensued, until I realised that I had in actual fact hashed out all the route info in the routing file. So message actually made sense. With that sorted out and the taxi details showing again I decided to press on.

My Online Taxi Booking System now looks like

Unfortunately the information doesn't came across as you can see by the following:

I am beating my head against a brick wall at the moment. Possibly mind gone blank syndrome. I definitely need to get back to RailsSpace, for another installment, which might clear things up a bit. In the meantime, I close this blog post with a screenshot of my pages_controller and file structure

You may notice that the Vehicle Controller is empty. I was getting some routing issues and so just moved the code into the pages controller. I am definitely thinking this was the wrong way to go. But that is where it is at the moment.

Update

Well after posting this blog, I had a slight rethink and put the Cabtype method back into the vehicle controller. The views all seem to work, and the cabtype view does get displayed after submitting the booking form. Alas the variables are not being initialised, so the cabtype view is not displaying the selected information. Any ideas anyone?

Wednesday, July 1, 2009

CSS and Ruby

I have just come across this Ruby gem which could be very useful for you all.
http://lesscss.org/
Less is Leaner css. Less extends css by adding: variables, mixins, operations and nested rules.
If you use css then this could be useful.

Monday, June 29, 2009

Some very helpful Ruby tomes

I have just going through Workshop 6 and the Topic reading: (Hartl)

This made mention of David Hannermeir Hansens 15 minute blog development presentation. http://media.rubyonrails.org/video/rails_take2_with_sound.mov in the introduction. I watched this (i suspect that Craig had recommended this earlier) and wish that I had seen this earlier in the subject.

Having watched the demonstration, I read (Collingbourne)

I now feel that I have a much better grasp of ROR, because of these references. I have gotten back into the first few chapters of (Hartl) and really wish that this had been recommended prior to Workshop 1. It goes through a nice seemingly simple step by step process for setting up rails, and actually specifies requirements. There is a distinct chance that maybe hindsight is playing a part in my thinking, remembering back to the number of lost hours trying to get a working setup.

However, what really got me to put this missive together was a single line in (Hartl, s2.2.1)

In case you ever need to undo the work done by generate, you can use ruby script/destroy controller . That's certainly a lot easier than deleting a bunch of files by hand.
which clarified in my mind where I had been going wrong in my attempts at building the OTBS. i may well have seen this before, but I don't remember seeing this in the same section as talking about generating the controller. But then again, this may well be hindsight in action.


References
Collingbourne, H (2008)"The Little Book of Ruby"
Hartl, M & Prochazka, A, (2008). RailsSpace: Building a Social Networking Website with Ruby on Rails, Pearson Education

Friday, June 26, 2009

Tuesday, June 16, 2009

Workshop 3: Building the model

The model has been built. Very ugly and definitely needs revision. But its a start.

This took a few iterations to get it to work. I started out with only a few fields in my model. Fell into a hole when, after having got that to work, I tried to add the remaining fields.

Still to do with this:

  • add look up values for passenger count, taxi-type, and building
  • get the site to look nice
  • lots more little things

Workshop 3: Much rejoicing

There is much rejoicing happening because I have just gotten MySQL to play nice with ruby.

I had been getting authentication issues, which resolved themselves by explicitly stating the localhost IP address (127.0.0.1) instead of using localhost in the database.yaml.

Additionally I had been getting the following error when trying to run the migration (rake db:migrate)

rake aborted! undefined method `each' for #

It turns out that MySQL 5.1 doesn't play nicely with Ruby and so the solution is to download an older copy of the MySQL client library. This link Aptana forum solved the problem.

So I now get:

>rake db:migrate
rake db:migrate
(in C:/Documents and Settings/Grant/My Documents/Aptana Studio/OnlineTaxiBookingScheme)
== CreatePassengers: migrating ===============================================
-- create_table(:passengers)
-> 0.0300s
== CreatePassengers: migrated (0.0300s) ======================================

Thursday, June 4, 2009

Newcastle Coders Group monthly meeting

I attended the latest monthly meeting of the Newcastle Coders Group last night (3 June 2009). On the agenda were talks discussing making application interfaces cool and using Ruby. The third item on the agenda was cancelled till next month. 'Cool’ Interface design with Luke Drumm Luke discussed the dynamics of a games engine and how it keeps a users interest by setting little tasks. Succesful completion of a task leads to the learning of skills which can be applied in future situations. This incremental skill level increase keeps the user happy and wanting to come back for more. The games paradigm is all about incentivising the user Luke compared the games interface mentality with the traditional business application approach which generally comes in one of 2 camps. Either the user is exposed to all the possible functionality and gets swamped with possibility, or the user has little exposure to functionality and at the same time is not shown how to progress. In either circumstance 95% of users use only 5% of an applications functionality. The main point that Luke put forward was that games designers treat the users like adults, with some intelligence, whereas business application designers treat users like children who need there hands to be held. (Please note that this conclusion came out in the discussion but has not been portaryed all that well in my discussion) Web Ready with Ruby with William Mason William gave a presentation about the ease of developing a website using Ruby. He was using the Ramaze framework. He built a basic food menu application and showed 4 iterations of the design. The adage that anything that can go wrong will go wrong in a presentation was very true. But he persevered and game a very quick overview of the design process. William used Netbeans as his IDE. Some useful (maybe) links that he gave are:

The thing that tied the 2 talks together for me is related to my experience with setting up a rails development environment. Luke says that people want to be treated like adults, which from his talk is based upon the premise that the user wants to investigate things for himself. There are times however when its good to be a child and being led by the hand is appreciated.

Wednesday, May 27, 2009

Workshop 1: Setting up Ruby on Rails

Well I decided that the Win7 environment was a little bit too progressive to try and get the Ruby environment operational. I was getting security issues with the Aptana IDE not recognising the MySQL installation. I downloaded MySQL v5.1 and tried to install that. The installation stalled when it was trying to create the initialisation file, so I was unable to set the root password or create the admin user. So I decided to start again. Last night I created a new VM and loaded XP SP3. I then loaded MySQL v5.1 and the MySQL v5 GUI tools. This time the installation went off without a hitch and I was able to create the initialization file. I installed Aptana, then installed the RADRails perspective, which loaded all the relevant gems. I created a default/ test project using SQLlite3 and this worked fine, first go. That working I attempted to create a project using MySQL as the database. Unfortunately there are still errors being thrown and it is indicating that their are missing files relating to the MySQL gem. This fails midstep. So I have decided that their is little prospect for me to be able to learn anything if I continue trying to get MySQL to work. Consequently all further work will involve me using SQLlite3 as the database backend. And thanks to Ken for giving that the ok today.

Monday, May 25, 2009

Workshop 1: Loading MySQL

I have been attempting to get MySQL installed on my VM for the past few days, have had no luck and am not going to devote anymore time to it.

I goy the Aptana IDE installed, and it seems nice enough, and relatively easy to use. I followed the demo video on Saturday and had to replay the steps a few times to see what options they selected. I got the example to work. Was unable to get anything working if I chose MySQL as the default database. I get errors stating that the machine is denying the request. I don't have a screenshot of the error message unfortunately.

Having had no luck I decided that I would attempt to install MySQL on the VM. As I said above, this has proven to be unsuccessful. As this course is not about Installing and configuring MySQL I don't believe it is worth the time to track down the cause of the issue.

This is a screenshot of the Aptana IDE showing the working test project. It may be that I am impatient, or far to used to a Windows wizard as far as installations go. I say that because the InstantRails install that I did left a lot to be desired. If you install something why do you then have to actually find the documentation that tells you how to configure it. Why wasnt that part of the installation process. I experienced this with the MySQL install as well. I only found the InstantRails config documentation tonight when I was trying to fix up the MySQL install. Well thats enough for now, back to the exercises. Until next time ...

Thursday, May 21, 2009

Workshop 1: Learning Ruby

Being used to and IDE I have downloaded Aptana and am currently loading the RADRails plugin The following link points to a video on creating a rails app in the Aptana Studio http://www.aptana.tv/movies/aptana_radrails_intro/aptana_radrails_intro.html Whilst watching the jar files being uploaded I can only hope that, not only does this run on Win7, but the security issues Craig mentioned with downloads dont raise there ugly heads.

Workshop 1: InstantRails podcasts

I have now listened to the entire series twice. It is not a bad way to pass the time on my commute. I guess I am looking forward to moving on from listening about Ruby on Rails at a conceptual level to getting my hands dirty in code and application development. A few observations first: I certainly hope that using ruby is fun, because Michael and Christopher kept telling me that using ruby was going to be "more fun" Having lived in the Visual Studio IDE for the past 5 years or so developing winforms apps, where seemingly all the tools are in one location, to be told I need to use a text editor, command line interface, subversion, etc etc etc was seemingly sounding like a step backwards. And this is going to be "more fun"? And then there is episode 8. Its all about the Mac. I chuckled to myself just a little thinking about apple - windows flame wars. Well now to get back into looking at what we need to do to get this workshop underway.

Tuesday, May 19, 2009

Workshop 1: Learning Ruby

I downloaded the Audio (Lessons 1-8) from LearningRails and also the Screencasts (Lessons 9-23). Having never used a podcast in any form before, and not one to burn music, copying these to a format I could listen to in the car on the commute to and from work turned into a challenge that wasn't.

An aside:

The iTunes player didn't work very well in burning to disk. This may have been for a number of reasons. There may be a bug in Win7 RC that caused my DVD burner to lose itself intermittently. The burner itself may have had a problem. The iTunes interface may have been my problem.

In the end I stopped using my main machine and used my laptop. This is a dell XPS1330 and also has Win7 RC installed. This showed the benefits of the homegroups concept introduced in Win7, and the ease with which network setup and connections is now handled.

Now back to the point of the blog. I finally got the podcasts (audio lessons 1-8) copied onto 3 CDs. Listened to the first 6 episodes today and found that they give a very good, yet brief overview of the Ruby language. Hopefully 7 and 8 tomorrow will give me some idea about actually getting started with Ruby development.