I am running Mac OX tiger with the installed ruby 1.8.2, and
mysql5 (I checked that it was running in preference). I
tried to run the various fixes recommended in agileweb. I am
stuck on page 57, script/generate scaffold…
Could you paste in your database.yml file, from the
“config” folder inside your Rails app? If you have any
passwords entered there, you should change them to
nonsense before sending.
I replaced the default list.rhtml with the copy/paste of the
text of page 67-68 from the rails-code.tgz and added the
text with copy/paste for page 69 scaffold.css.
I get an error message which starts with
compile error
script/…/config/…/app/views/admin/list.rhtml:1: syntax
error
_erbout = ‘’; _erbout.concat “
Without seeing the rhtml I can’t offer a definitive reason. When I get
syntax errors like this I usually back out whatever I have added to my
RHTML, and add it back incrementally to spot the error.
cellspacing="0">\r";
"; _erbout.concat(( h(truncate(product.description, 80))
is the same as in the book. How do I debug a syntax error
like this?
Can you paste in the code? Usually the “line 1” error means that
you’ve got a <% or <%= opening tag that isn’t closed. Unfortunately,
these “totally couldn’t handle it” error messages are the hardest to
track down. Luckily, they usually end up being something really
simple. You can find them with an editor that has serious syntax
highlighting (like vim or TextMate).
If you’re using something else, you can chop it up into pieces and run
it a bit at a time. Add one block of code at a time, until you find
the error.
Of course, right after I posted this info, I realized that
there are two languages intermixed, the % language and the
table language. And the first few lines start a for loop
which is closed just before table is closed.
Once I understood that, I was able to modify the list file
little by little. It was cool to watch the changes happen.
The book does not bother explaining anything, so at least
with this method, you can guess what is going on, and look
it up if it is of interest.
I added the lines little by little, taking away lines also
until the list file was the same as far as I could tell as
the book’s file I was copying from, and no syntax error. —
the pictures did not load, oh well ~/Desktop/image.jpg —
I recopied the original text from the code download into
the list file, and the syntax error came back.
I will try again tomorrow. Thank you for your advice
this is the text copy pasted from the list.rhtml file from
the book’s rails-code.tgz from folder depot4: list.rhtml
should be as listed page 68.
text wrangler does put some colors, I did not see any
mismatch. I start geting an error as soon as I put the
first lines with <% … %> that seems to define some macro,
don’t know why it would triger an error.
Product Listing
<%
odd_or_even = 0
for product in @products
odd_or_even = 1 - odd_or_even
%>
Rails normally has an rhtml file on the server which is
interpreted. If the rhtml has a load image command,
it loads the image and presents it to the user.
Is there a way to have Rails load all the images that are
going to be used ahead of time? How would the code look
different?
usually the user clicks on submit, which is really a link
which is interpreted as a request by the controller.
Is there a way to have Rails respond to a key press
by storing the content of the key press and moving on to
load the next image
As I understand it, the timing is mostly controlled by the
user clicking on a link. Until then the server just sits
there waiting for someone to request a link
How can I use Ajax to control the timing of the presentation
independently of a link request?
So that is a problem that people are thinking about, and
there are ways to do it. I know that rails gives access to
javascript through helper functions, so I am wondering if
the ability to load pages all at once, or images all at once
is available in rails.
I hear that the Times has set it up so all the articles load
up at once, so reading the paper is very fast, the articles
are already there.
for key presses, it might be more difficult, people seem
more focused on the mouse, on mouse roll over… but if they
give mouse interactivity, they give keyboard interactivity.
It seems to me that as web application are taking over
behaviors of computer applications, they will need to do all
the things a computer application can do, but we may be at
the beginning of that era. Flash can do all I want to do,
and it is loaded into and runs from a browser, but other
tools like Rails may not be able to do such things yet?
I can always find my post on the web archive, but I don’t
usually find them in the gmane rails archive. Yet they are
mirrors of each other, no?
Very strange, this morning, the error was there. I went
backward, taking code out chunk by chunk, but some error was
there all the way. until I went to a blank page.
I restarted with the download file, and now I don’t get any
error. I can’t get the error even with the old files I
believe gave the error.
I tried editing the path of the image to image that are
already in the images folder in public,
image url
/images/sk_auto_small.jpg
/public/images/sk_auto_small.jpg
…
nothing works.
It’s available the same way it’s always been available - through
judicious use of the right bits of HTML, Javascript and CSS. There
aren’t many bits of Rails that specifically help browser pre-caching, or
hidden div loading, but then there’s nothing to get in the way either…
I hear that the Times has set it up so all the articles load
up at once, so reading the paper is very fast, the articles
are already there.
Not that I can see… Have you got a reference for that?
for key presses, it might be more difficult, people seem
more focused on the mouse, on mouse roll over… but if they
give mouse interactivity, they give keyboard interactivity.
Again, this is an HTML/Javascript thing, not Rails-specific. There
might be some functionality in RJS templates to help out, but I can’t
think of any off the top of my head. The accesskey attribute on form
elements and links might be enough to give you the keypress
functionality you want.
It seems to me that as web application are taking over
behaviors of computer applications, they will need to do all
the things a computer application can do, but we may be at
the beginning of that era. Flash can do all I want to do,
and it is loaded into and runs from a browser, but other
tools like Rails may not be able to do such things yet?
There’s nothing really technologically new Rails brings to the table.
It just ties everything together in a really tidy package.
Use of the image Image-Name-1.gif in subsequent pages will
be loaded from chache.
that should do the trick, load all the images at the start.
But where do I put this javascript code in a rails project?
Put that code in a template that will get loaded by the browser before
the images are needed. Maybe in the head of application.rhtml, if it’s
site-wide.
On another programming list on which I’m active, I’ve (of course)
mentioned my newfound interest in and focus on Rails. One of the long-
time members, a pretty thoughtful guy, has emailed me privately and
asked me if I could point him to any Rails apps that were handling
huge amounts of traffic. I’ve had the usual conversations with him
about what scalability really means, how few sites need to handle
huge amounts of traffic, how Rails is just one component of the
landscape, etc.
Still, he wants to know if I can point him to any large-scale apps
done in Rails. Is there an answer to this question? Or is it just one
of those diversionary issues raised by people who are looking for
some reason not to spend the time to evaluate a new technology deeply
enough to draw their own conclusions?
A couple of the more well known applications would be 43 Things
(http://www.43things.com/) with somewhere between 500K and 1MM
requests per day and Basecamp (http://www.basecamphq.com/) with over
100,000 users. Others on the list can probably give you more
specific examples for these two applications as well as others.
I get an error message
access denied for user ‘root’@‘localhost’ (using password
no)
which is strange because mysql is setup with a password, and
I gave it in the config file, database.yml.
I am probably missing a piece which is normally setup by
scafold, is that so? what do I need to do?