The new sort feature reveled an issue with the database data. Some of the fields have white space at the beginning. These were sorted to the top of the list. This is technically correct but not what I want to see. I made a small change to the Perl code that scrapes the HTML coffee review files and puts the data into the database tables used by coffeeFind. Now I make sure there's no leading white space. Fixed. [/items/Rails] permanent link
Fri, 27 Jan 2006
I finally circled back around and started poking at my CoffeeFind /*Ruby on Rails*/ application again. I stayed up way late. I wanted to get the [sort-by-column http://pwizardry.com/devlog/index.cgi/2006/01/06#CoffeeFind_I_Want] feature working and I couldn't quit in the middle. *Lessons learned:* just a random list so I don't forget...
- You have to start WEBrick from inside the application directory, /seems that way anyway.../
- To pass params from view to controller. In the view I do this: /<% link_to "![sort]", :action => "show_ordered_by", :id => by %>/ The param here is "by" which is set up above: /<% by = column.name %>/ I needed to do this because no matter what I did with quotes I couldn't just put /column.name/ as the :id value. This bit of code is used in a loop to put a sort tag on each of the column head cells so I can signal the controller method to sort on that column.
On the controller I have: /def show_ordered_by/ /@reviews = Reviews.find(:all, :order => @params['id'])/ /end/ The @params array has the /id/ value the link will pass.
I had added the /*show_ordered_by*/ method to be the target of the links that will resort the table. I needed a separate view .rhtml file to display it. This file turned out to be identical to the one for the /*sort*/ method that draws the table the first time you view the link. In accordance with the DRY principle I changed the /*sort*/ method to be: /redirect_to :action => 'show_ordered_by', :id => 'id'/ And for good measure I added a /*index*/ method which is identical. This way you just need to use [http://pwizardry.com/review http://pwizardry.com/review]
Sat, 07 Jan 2006
At last! I'm done installing and can finally continue the application development. *Dev Notes* It's a database of green coffee bean reviews. The database is /coffeeFind_development/, the table is /reviews/, and the column names are scraped from the web page table with the reviews. I know, or can find out, what the column names are, but I'm going to get them from the db. I may want to hint at the order I want... later... To start, I took the scaffold list code and called it [= SITE/review/show]. I added a show method to app/controllers/review_controller.rb. For that I also copied the admin version. It still didn't work untill I added apps/views/layouts/review.rhtml. I made it like the admin.rhtml one. [/items/Rails] permanent link
Fri, 06 Jan 2006
as of
- To sort by clicking on column title name
- To have the column heads vertical
- you can maybe do that with css -- or it will be ruby
- This *can* be done with ruby and regex
- There will be links to the reviews
- Which means maybe I have to know the name of that column...
- Or maybe I fix the content to look like a URL and detect that...
- some other stuff
Column headers will be vertical... ruby -e "a = 'BodyMovement';a.gsub!(!/([a-z])([A-Z])!/, '\1 \2'); a.gsub!(!/(.)/, '\1<br>')" --> B
o
d
y
M
o
v
e
m
e
n
t
[/items/Rails] permanent link
Thu, 05 Jan 2006
I explain why I installed Typo last post. It was basically just because... *but how?* Typo, like my Rails install, was smooth. I just followed the instructions and it almost worked. I started the server and it served a blank page. Or maybe I should call it a NULL page. It had no HTML at all. No errors were logged nor were there any other signs of trouble. As it turned out Typo wasn't able to connect to mySQL. I didn't know that at the time but as I ran through my debugging thrash I remembered a little unfinished business from the Rails install. As I mentioned yesterday /(or day before -- it's after midnight now./), the Ruby Gem /mysql/ wouldn't install. Rails worked without it but I decided to see if I could get the gem to go in anyway. I don't like it when things don't work. The mysql gem was advertized as the fast C bindings for mysql. Running [= gem install mysql] gave the message: [= ERROR: While executing gem ... (RuntimeError) ERROR: Failed to build gem native extension. ruby extconf.rb install mysql\nchecking for mysql_query() in -lmysqlclient...no ![and more messages like that ...]] A clue tunes out to be that "-lmysqlclient" which seems to mean something like "use lib (-l) mysqlclient.so". Since the automatic gem system wouldn't install, I went out and found the package for manual install on a Japanese site called [tmtm.org http://tmtm.org]. The english version of the lib page is [here http://tmtm.org/mysql/ruby/README.html]. It didn't work at first either, and spit out the same errors as the gem version. The difference here was the availability of the option: [= --with-mysql-dir=dir] The error said it couldn't find mysqlclient.so and I see it in the shared version in /usr/local/mysql/lib but not in the version I'm using. That's the one I installed from binaries the other day to cure my Rails problem. In the end, once I copied the libs from the root version to my version, and pointed to it with the magic option, the build and install went fine. After that Typo worked fine too. It only took a half day to install. ---- [/items/Rails] permanent link
Wed, 04 Jan 2006
As an experiment I installed [Typo http://typo.leetsoft.com/trac/] here. It's a full featured, database backed, blogging system written in ruby. It was another entertaining struggle due the virtual server environment used at Verio where pwizardry.com is hosted. I'll get into the interesting *how* discussion in a sec. First I should explain to myself *why* I did it. *why?* I don't really /need/ another blogging system. I don't even think of this as a weblog. It's more of a way to keep notes for myself on tech projects. I just happen to find Blosxom is a good way to do it. I have several Blosxom's on various servers for different purposes. At work I got into the habit of working on a weekly report as a series of postings. I multi task so much some times I can't really remember what all I did any other way. So why? I blame it on Blosxom, or rather Rael Dornfest, the guy who wrote Bloszom. I have a link to his ["raelity bytes" http://raelity.org] site is on the left column here. I clicked it yesterday and he has a shinny new Typo blog. It looked good and at first I wondered where he got the great Bloszom theme. The first post I saw that day was about his new Ruby on Rails work. Now I just dived into Rails myself. My recent postings here have been about the tricky Rails install on the shared server setup here. So, I got the tech itch for Typo and I just had to scratch it. It took a while has it turned out. I'll put the how part in a seperate post. ---- [/items/Rails] permanent link
Tue, 03 Jan 2006
Yesterday I mentioned the problems I had installing Ruby DBD/DBI. There's a lot more I could say about that today. First, I doesn't look like Rails needs DBI so getting DBI to install shouldn't have made Rails start working. (Should it?) In fact, a short program to test the DBI function errors out... A more likely explanation, then, is that installing and running mySQL from my own space was what's needed. As a side note - I tried to take this advice at the top of the Rails config file database.yml: [= # Get the fast C bindings: # gem install mysql] but this is what I get: [=Attempting local installation of 'mysql' Local gem file not found: mysql*.gem Attempting remote installation of 'mysql' Building native extensions. This could take a while... ERROR: While executing gem ... (RuntimeError) ERROR: Failed to build gem native extension.] No joy there, but like I said, Rails did start connecting to mySQL anyway. I'll just document my DBI problems and move on. The errors I was seeing are these: [= pwizardry% ruby setup.rb install setup.rb:586: warning: parenthesize argument(s) for future version entering install phase... mkdir -p /usr/home/lyon/local/bin install sqlsh.rb /usr/home/lyon/local/bin install failed Inappropriate file type or format - /usr/home/lyon/local/bin/sqlsh.rb] The file sqlsh.rb was there and ruby -c says [="Syntax OK"] and I don't see anything wrong with the file either. Ah well, I will move on for now. As a scientist I always want to know why but as a Practical Wizard I first want to get it working. One problem for the scientist here is the old "I tried A and B and C and D and ... and then it worked. Was it the last thing I tried? Or was it some combination? Which one? A carefully designed experiment would answer that but that's not next on my task list. ---- [/items/Rails] permanent link
Mon, 02 Jan 2006
I spoke too soon last post. I did have Ruby and Rails installed and "working" all right, but Rails couldn't connect to mySQL. Since easy database integration is the main point of Rails I'd have to say that it wasn't really working after all. I did manage to get it to work after a lot of gymnastics though. First I realized the Ruby DBI modules weren't installed. I thought those went in with the standard install. Maybe not, or maybe it has something to do with the fact that mySQL was running from /usr/local/bin which belongs to root. The instance running in my space belonged to me but the "I don't own mySQL" theory turned out to be my best guess about the cause of my problems in the end. I tried to install the DBI/DBD but it didn't want to go. One of the things I tried is installing my own version of mySQL. I still couldn't get DBI to install. It kept quitting with a mysterious error about a file it installed having the wrong file type or format or something!?! I finally ran the installer in verbose mode and found out what it was trying to do. I then did everything by hand and it worked. Not right away of course. I also had to stop and start the server and kill my shell and log in again. Then I went away thinking it was still broken and came back and refreshed by browser for the n+1th time. And Bang! It was just working. I said Wow and my wife came in to see what was so great. It was a page where I could add a record to my database table. It replaced a page full of verbose error messages and debugging info. The add record worked too. It knew everything about my database table though all I gave it was the database name, the user, and password. I also gave it the table name through the "scaffold" tool. For that I got view/edit/add pages. Not bad. This morning I tried shutting down my version of mySQL and starting the /usr/local/bin one once again. It still didn't work. I'm not positive I couldn't get it to work but I'm not going to bother for now. The answer seems to be to use my own versions of everything in this virtual server environment. [/items/Rails] permanent link
Wed, 28 Dec 2005
Ahhhh, that feels good... I tried again today and got Ruby and Rails installed and working in less than an hour. The trick to getting Ruby to install in my own space is an option in configure: [= --prefix=PREFIX] where PREFIX is my own version of /usr/local, ~/local. Once I did that, and make/make install and put ~/local/bin in my path, I was on my way. Gems and rails went on and ran with no problem. So far so good. [/items/Rails] permanent link
Fri, 07 Oct 2005
I've given up, for now, trying to put Rails on Pwizardry.com. It may be possible but I haven't yet discovered how. Then again, it may be impossible. Instead, I installed it on an old Redhat Linux box in the back closet. This ment installing Ruby from source first. I tried using RPM's but my version of Linux on this box is too old. It took me hours to find this out because the rpmfind system was extra constipated that night. Also, when I click on a ruby RPM I still get a Real audio interface that's trying to open. Sick! I installed Ruby 1.8.3 and rubygems. Then I put in rails using gem. Then I found there is a bug in the 'rails' command: ==== error message: [= !/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1 \ /lib/active_support/clean_logger.rb:13:in `remove_const': constant Logger::Format not defined (NameError) ] The hacky fix is to comment out line 13... I see there is a fix but I should have used Ruby 1.8.2 ---- [/items/Rails] permanent link
Tue, 27 Sep 2005
I'm trying to find out if it's possible to install Rails on Verio. None of the how_to's seem to cover the type of environment I see here. I see Ruby is there in /usr/local/bin which may be a good start. I'm not sure about that though. It may turn out that I need to install my own version of Ruby and Rails. I don't know enough about how they work yet. I don't know enough about how the virtual domain server thing works here either. Lot's to find out. I see /usr/sbin/bkg_add too which may be a part of the puzzle. ---- [/items/Rails] permanent link