|
If anyone likes watching Ruby conference talks, these links came my way: http://goruco2008.confreaks.com/ http://mtnwestrubyconf2008.confreaks.com/ About 3.5 GB of nicely formatted talks (so far).
|
# ? May 4, 2008 15:36 |
|
|
# ? May 6, 2024 14:05 |
|
I'm trying to figure out how to farm off some code in one of the railcasts into a helper. It's from #74: Complex Forms Part 2.code:
|
# ? May 6, 2008 18:56 |
|
I kind of sort of got beyond that. I ended up having to tag the rows with unique identifiers; I couldn't find a way to have it dynamically move relative up in the DOM and delete itself from within a helper. The problem I have now is that Ruby code in my link_to_function gets evaulated immediately, rather than when the event triggers. I guess it doesn't completely surprise me, but I need something like lazy evaluation. The problem is that I am trying to remove things from an array within a link_to_function field. Since that gets evaluated when the page is rendered, it starts deleting immediately. The block looks like this: code:
|
# ? May 8, 2008 07:02 |
|
Rocko Bonaparte posted:My server console output prints "REMOVE DO BODY" when I request the page. Is there something I can do so that the code is instead embedded into my page and only triggers when I click "Remove?" Are you wanting the code to execute on the server when it is clicked? If so you should probably look at link_to_remote.
|
# ? May 8, 2008 13:01 |
|
Hop Pocket posted:Are you wanting the code to execute on the server when it is clicked? If so you should probably look at link_to_remote. 1. The row disappears from the client's screen. 2. The server's understanding of the list removes that row. Could I have that all done on the client side anyways? Really the server doesn't need to know that stuff.
|
# ? May 8, 2008 17:39 |
|
Rocko Bonaparte posted:2. The server's understanding of the list removes that row. ... Really the server doesn't need to know that stuff. code:
code:
code:
|
# ? May 8, 2008 19:29 |
|
skidooer posted:
The server is there to pump down the initial page, and hopefully provide data for things that could be populated into the array. Edit: Just to get back to the core problem, I need the system--be it client or server--to not remove elements from the array when the page is first loaded. It should only happen when when the link is clicked. Right now, it's deciding to nuke the specified element from the array each time I create the removal link. So my page is creating, say, 3 items. I get to the point where I'm making the view. Each time I add a link_to_function that has the array removal code in the body, it's actually executing it right on the spot. So by the time the page is done loading, I have nothing in my array anymore. Rocko Bonaparte fucked around with this message at 21:03 on May 8, 2008 |
# ? May 8, 2008 21:00 |
|
Rocko Bonaparte posted:Edit: Just to get back to the core problem, I need the system--be it client or server--to not remove elements from the array when the page is first loaded. It should only happen when when the link is clicked.
|
# ? May 8, 2008 22:14 |
|
skidooer posted:I think we need to see some more code. What exactly is in this array? Right now the array is created in the controller: code:
code:
code:
|
# ? May 8, 2008 22:37 |
|
Rocko Bonaparte posted:Right now the array is created in the controller: fermentables_controller.rb code:
code:
code:
|
# ? May 9, 2008 00:34 |
|
skidooer posted:The web is stateless. That array will be recreated on every page load, even if an element has been removed. I'm thinking that's not what you want at all. You will probably want to rethink your application design, but without changing what you have too much: No I actually wanted a new array on each load of that page. I was hoping my tool would come up and I could just interact with that. The default data I had in there is just for experimenting, but normally that would initially come up blank, and I would start adding my things in. Really, it's more like a client application that I want to be able to run from any computer with a browser. Update: I've read up a little bit more on all this stuff. What I want to try to do is get the client aware of all these objects and arrays, and have all the work done client-side. The server would initially serve the page, and occasionally do some AJAX goodness to give the client some data. Right now, the array is declared in the controller. I don't see it get declared on the page that is generated for the client, so the client has no awareness of the array. Is there a way--using Ruby code--to declare the array on the client side? Also, I know I can use link_to_function to handle a line of JavaScript, but is there a way to use Ruby code and have rails turn it into JavaScript when rendered? I am trying to reduce the amount of languages I'm throwing around in this app. Sure, it can be JavaScript when it's run, but I'm trying to make it Ruby code that I am actually typing. Rocko Bonaparte fucked around with this message at 18:11 on May 9, 2008 |
# ? May 9, 2008 01:35 |
|
skidooer posted:You can use fields_for to specify an additional object. Thanks, this worked perfectly I'll also have to check out those rubycast because I've got no idea what's going on with this code here.
|
# ? May 13, 2008 01:34 |
|
This is more of a general ruby question, but how the hell do I unpack a utf8 string in ruby 1.8 and get it so that \xC2\xAE actually shows up as ® in the output? I've never really done this stuff, and feel sort of lost googling around.
|
# ? May 25, 2008 21:31 |
|
DoubleDamnit post
|
# ? May 25, 2008 21:31 |
|
dustgun posted:This is more of a general ruby question, but how the hell do I unpack a utf8 string in ruby 1.8 and get it so that \xC2\xAE actually shows up as ® in the output? I've never really done this stuff, and feel sort of lost googling around. This may work for you: code:
Pardot fucked around with this message at 01:32 on May 26, 2008 |
# ? May 26, 2008 01:30 |
|
Perfect, thanks.
|
# ? May 26, 2008 19:48 |
|
Anyone going to be at railsconf?
|
# ? May 28, 2008 15:28 |
|
Pardot posted:Anyone going to be at railsconf? I'm on the train from Seattle, heading down right now.
|
# ? May 28, 2008 22:37 |
|
Can I inherit from a class defined in a module?code:
|
# ? Jun 3, 2008 23:20 |
|
Cylon Dinner Party posted:Can I inherit from a class defined in a module? ...
|
# ? Jun 4, 2008 00:25 |
|
skidooer posted:class Smsg < ModuleName::Message ... Thanks! You came through where my google fu failed. Please accept my apologies, if the Rails thread is not meant to double as Ruby Stupid Questions.
|
# ? Jun 4, 2008 00:32 |
|
Cylon Dinner Party posted:Thanks! You came through where my google fu failed. Please accept my apologies, if the Rails thread is not meant to double as Ruby Stupid Questions. I mentioned this in the merb thread too, but I think a general ruby megathread would be better. I'm sure the tread would be just like this one, mostly rails but some random ruby stuff. Maybe we should just get the name of this thread changed.
|
# ? Jun 4, 2008 02:00 |
|
Is there a way to break/continue multiple levels in Ruby? Say I have a each loop inside an each loop, and I want to the inner loop to be able to issue a continue to the outer one. This would be an example case: code:
|
# ? Jun 13, 2008 13:27 |
|
Opius posted:If it's not possible to break multiple levels, how should I go about dealing with nested loops and flow control? From what you posted, this comes to mind: code:
|
# ? Jun 13, 2008 17:09 |
|
Not strictly a Rails question, but I am using ActiveRecord to access a database. What is the best way to convert table attributes to a hash? For example:code:
Carabus fucked around with this message at 19:53 on Jun 16, 2008 |
# ? Jun 16, 2008 18:11 |
|
Carabus posted:What is the best way to convert table attributes to a hash? code:
|
# ? Jun 16, 2008 19:32 |
|
I should try to figure this out myself, since I only understand part of your code and my purpose is to actually learn the language. The exercise is from this book. I made a clumsy ruby port of one of the Python scripts from the book, not as good as this version at Github but it works. I have a table to work with which has a columns for user, rating, and rateable. It was easier than I thought to port from Python to Ruby but this has posed a bit bigger challenge for me, even though I know it should be simple. So if anyone is interested in this sort of thing, take a look and I would appreciate any suggestions but thanks for the help already, skidooer.
|
# ? Jun 16, 2008 21:12 |
|
So I've been playing around with Ruby lately, did all the Lucky Stiff stuff and so on, and now that that's been going great I was wondering whether it's possible to make something I created with Shoes into a "real" .exe-File. Is that even possible with ruby?
|
# ? Jun 17, 2008 21:36 |
|
unleash the unicorn posted:So I've been playing around with Ruby lately, did all the Lucky Stiff stuff and so on, and now that that's been going great I was wondering whether it's possible to make something I created with Shoes into a "real" .exe-File. I could be wrong, but I don't think you can do that with something like shoes. I think the best you can do is do something in jruby and package that into bytecode. I haven't looked into any of this myself, but I think there is at least one jruby UI thing. This is all just vague recollections from my rss feeds, though.
|
# ? Jun 17, 2008 22:08 |
|
Hmmm, thanks. Could anyone point me to a good how-to for making ".shy" files instead? I can't seem to find anything, and googling "ruby shy" leads to some "mygayweb" site which I don't really have the guts to explore.
|
# ? Jun 18, 2008 19:34 |
|
Pardot posted:I could be wrong, but I don't think you can do that with something like shoes. I think the best you can do is do something in jruby and package that into bytecode. I haven't looked into any of this myself, but I think there is at least one jruby UI thing. This is all just vague recollections from my rss feeds, though. quote:Okay, the latest set:
|
# ? Jun 19, 2008 17:26 |
|
Yeah, I saw that too. Awesome!
|
# ? Jun 19, 2008 20:54 |
Okay, Site5 loving sucks. What's the latest round of suggestions for a Rails/Ruby framework friendly host -- and what's the score on hosting providers picking up on Phusion Passenger aka mod_rails? Damnit going to have to move all my sites again grumble grumble
|
|
# ? Jun 25, 2008 19:09 |
Okay, so since apparently no one is actually deploying Rails projects, I have another question Say we have a User model, and a Recipe model, and Recipe belongs_to a User. If I want to retrieve the number of recipes a user has, I can do something like Recipe.count( :conditions => [ 'recipe_user = ?', user_id], :include => :user), but what if I wanted to cache that number, so it wasn't calculated every time I had a list of thousands of users? Should I just add another table column and run a rake task every 30 minutes or so that re-calculates and UPDATEs that column for the Users table? Or is there a more sensible way of dealing with this? EDIT: Oh hey, counter_cache. Hooray! See here for details if you have the same question: http://railscasts.com/episodes/23
|
|
# ? Jun 29, 2008 17:19 |
|
shopvac4christ posted:Okay, Site5 loving sucks. What's the latest round of suggestions for a Rails/Ruby framework friendly host -- and what's the score on hosting providers picking up on Phusion Passenger aka mod_rails? Not sure about whether if mod_rails is production ready yet. Personally, I have a slice on slicehost.com, but I haven't deployed an app there yet. They also have Rails-ready slices. At work we use EngineYard. We pay out the rear end, but they make up for the price in the support you get.
|
# ? Jun 30, 2008 01:48 |
|
shopvac4christ posted:Okay, so since apparently no one is actually deploying Rails projects, I have another question No, some of us have Rails projects in production. Forumwarz, my MMO, is deployed on a dedicated host. The technology is Nginx proxying to a pack of Mongrels. I don't have any recommendations for small projects, but if you are doing mid-sized traffic (right now we're doing 20 dynamic rq/sec) a dedicated server is quite affordable at most hosting companies. I just assumed that since you said you were interested in Phusion that you were working on something smaller.
|
# ? Jun 30, 2008 03:14 |
Grob posted:No, some of us have Rails projects in production. Forumwarz, my MMO, is deployed on a dedicated host. Well, that's the thing. I don't have *any* projects because I don't trust myself to do deployments, and I don't do any deployments because I don't have sufficient hosting, and I don't feel it's necessary to pay out the rear end for hosting on projects that for all intents and purposes aren't valid public projects, but just me playing around with the framework. So it's a conundrum.
|
|
# ? Jun 30, 2008 15:13 |
|
shopvac4christ posted:Well, that's the thing. I don't have *any* projects because I don't trust myself to do deployments, and I don't do any deployments because I don't have sufficient hosting, and I don't feel it's necessary to pay out the rear end for hosting on projects that for all intents and purposes aren't valid public projects, but just me playing around with the framework. So it's a conundrum. Capistrano makes deployment pretty easy. In my case I have an nginx frontend proxying to thin instances. I use god to keep the memory usage in check and backgroundrb running.
|
# ? Jun 30, 2008 15:31 |
jonnii posted:Capistrano makes deployment pretty easy. In my case I have an nginx frontend proxying to thin instances. I use god to keep the memory usage in check and backgroundrb running. That's what I've heard, but I haven't had a chance to actually try it. That's what I'm asking. Where are people deploying their projects? Their one-off, unimportant stuff? I'm not shelling out 400 dollars a month for an Engine Yard slice. I'm still in college, you know?
|
|
# ? Jun 30, 2008 15:54 |
|
|
# ? May 6, 2024 14:05 |
|
Slicehost is priced pretty fairly with their lowest VPS only $20/month. If you can't afford that, you might as well just run things on localhost because I don't think anything else is available. I guess you could try Dreamhost--they are now using Passenger / mod_rails.
|
# ? Jun 30, 2008 16:08 |