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?
Hi Grant,
ReplyDeleteYou're right the cabtype method should be in the vehicle controller.
The bookcab form should have the following:
<form action ="vehicle/cabtype" method = post>
so it posts the variables to the vehicle controller, cabtype method.
the cabtype method looks right, so make sure your bookcab.html.erb has the same variable names eg
<input type="text" name ="text1">
equates to
@data1 = params[:text1]
in the cabtype function where text1 is the name of the text box and the parameter.
Just looked at this again and the path to your page is pages/cabtype so the cabtype method in that case is pointing to the pages controller. what does your bookcab.html.erb have in it?
ReplyDeleteKaren, if you look at my subsequent post, I have rectified my problem, and moved my vehicle bits out of the pages controller all together. Th pages controller now knows niothing about the cab bookings, which is how it should be.
ReplyDelete