|
Soup in a Bag posted:Unfortunately there can be a problem using a default object: Oh yeah, my bad The last several times I used that feature, I had 0 as the default object, which doesn't have that problem. Pardot fucked around with this message at 05:20 on Jun 17, 2011 |
# ? Jun 17, 2011 05:18 |
|
|
# ? May 14, 2024 10:48 |
|
Dooey posted:My irb stopper working Isn't reload! particular to the Rails console? I don't think vanilla irb has anything like that.
|
# ? Jun 17, 2011 12:16 |
|
enki42 posted:Isn't reload! particular to the Rails console? I don't think vanilla irb has anything like that. code:
|
# ? Jun 17, 2011 13:24 |
|
How do I add a method at runtime? I created a new class (Adder) and a constructor that takes a single integer argument. I added a method named missing_method. When I invoke object.plus10 on an object of the class, I need my code to add a method for plus10 (generally, plusnum for any number) at run time within missing_method. 1) How do I discuss the literal contents of the missing method in Ruby so I can examine it and then create a method from it? 2) My class takes an argument such that the argument ought to become the "identity"(?) of the object (x = Adder.new(10) creates an integer-like object (x => 10)). I got this far (below). How do I make it so that x => 10? code:
|
# ? Jun 17, 2011 15:41 |
|
Good morning, I am working on a ruby file that calls a powershell interpreter and when I try to upload the file I am receiving the following error: (using Chef for server automation) FATAL: Cookbook file recipes/create_bin.rb has a ruby syntax error: FATAL: /home/noc/chef-repository/.chef/../cookbooks/powershell/recipes/create_bin.rb:104: invalid multibyte char (US-ASCII) FATAL: /home/noc/chef-repository/.chef/../cookbooks/powershell/recipes/create_bin.rb:103: syntax error, unexpected $end, expecting tSTRING_CONTENT or tSTRING_DBEG or tSTRING_DVAR or tSTRING_END Here is the code that contains lines 103 and 104: ******** powershell "New-Item" do #Create a directory and assign permissions code <<-EOH $new-item C:\bin –Type Directory $get-acl C:\bin | Format-List $acl = Get-Acl C:\bin $rule = New-Object System.Security.AccessControl.FileSystemAccessRule("Administrators","FullControl", "ContainerInherit, ObjectInherit", "None", "Allow") $acl.AddAccessRule($rule) $rule = New-Object System.Security.AccessControl.FileSystemAccessRule("chef","FullControl", "ContainerInherit, ObjectInherit", "None", "Allow") $acl.AddAccessRule($rule) $rule = New-Object System.Security.AccessControl.FileSystemAccessRule("Users","Read", "ContainerInherit, ObjectInherit", "None", "Allow") $acl.AddAccessRule($rule) Set-Acl c:\bin $acl Get-Acl c:\bin | Format-List EOH end ********** and here is the link to the entire doc http://codepad.org/SZZqzV43 Can anyone tell me why I am getting a syntax error here? I can't figure it out. =(
|
# ? Jun 17, 2011 17:15 |
|
quote:and here is the link to the entire doc
|
# ? Jun 17, 2011 17:24 |
|
Well I actually am choking on a ruby error, since chef is checking the .rb file against ruby syntax- so the powershell part of it is moot right now aside from the fact that it has to pass ruby syntax muster. I'll look into that, thanks. I am sorry for the spam, but I cannot seem to find the error here. I double quoted and escaped the slashes, but now can't find any problems. http://codepad.org/AgwDrLY5 Defghanistan fucked around with this message at 18:09 on Jun 17, 2011 |
# ? Jun 17, 2011 17:36 |
|
Jam2 posted:How do I add a method at runtime? This is something that really should be used sparingly, but for the sake of learning: code:
code:
|
# ? Jun 17, 2011 18:18 |
|
Defghanistan posted:http://codepad.org/AgwDrLY5 edit: Oh, I see, I am not familiar with codepad. The error is pretty straightforward, you are missing the require that provides the powershell method. Obsurveyor fucked around with this message at 20:28 on Jun 17, 2011 |
# ? Jun 17, 2011 20:25 |
|
Defghanistan posted:Well I actually am choking on a ruby error, since chef is checking the .rb file against ruby syntax- so the powershell part of it is moot right now aside from the fact that it has to pass ruby syntax muster. I'll look into that, thanks. You're still getting the same error? I'm guessing that this: "invalid multibyte char (US-ASCII)" is the important clue. Just looking at line 104 in your first paste (line 10 in your latest paste), it seems like the '-' in "-Type Directory" is bigger than your other '-'s. Maybe that's what it's complaining about?
|
# ? Jun 17, 2011 20:49 |
|
enki42 posted:Isn't reload! particular to the Rails console? I don't think vanilla irb has anything like that. I did not realize they were different. Thank you.
|
# ? Jun 17, 2011 23:54 |
|
Dooey posted:I did not realize they were different. And so it goes. Still wonder where Ruby would be today without DHH turning it into a slightly more expressive PHP... My guess: much less popular, but also much less pigeonholed and overshadowed by a single framework. Meh.
|
# ? Jun 18, 2011 03:57 |
|
bitprophet posted:Still wonder where Ruby would be today without DHH turning it into a slightly more expressive PHP... The language at its core is rotten, Ruby is not(and has nothing to do with Rails, really). If you hate Rails, use Sinatra and roll your own poo poo all day, every day. Obsurveyor fucked around with this message at 05:00 on Jun 18, 2011 |
# ? Jun 18, 2011 04:57 |
|
So I ran the update for Rails on my Mac OSX and realized that there's really something wrong with the "rails" command whenever I get it typed. Following the tutorial on the Ruby on Rails site, Typing "rails new blog" gets me a directory called "new" instead of "blog". Typing "rails server" populates my server directory with files instead of starting the server. Anyway to fix this? I have to use ./script/<command> to now to get things done.
|
# ? Jun 18, 2011 05:08 |
|
Mudoubleha posted:So I ran the update for Rails on my Mac OSX and realized that there's really something wrong with the "rails" command whenever I get it typed. It seems like your rails did not actually get updated to 3 for whatever reason. Also I'm assuming you're still using the ruby that came with osx, so while you're taking the time to get up to date and all that, you should 1) install rvm https://rvm.beginrescueend.com/ 2) rvm install 1.9.2 3) rvm --default use 1.9.2 4) gem install rails
|
# ? Jun 18, 2011 05:26 |
|
Obsurveyor posted:Care to expand on that or are you going to leave it at vague musings? I meant more about how both are essentially consigned to be Web-only languages, except Ruby is actually an excellent general-purpose language but still gets pigeonholed into "lol Rails" / "lol Web" because of the inordinate influence Rails has on the Ruby ecosystem. So you end up with a flood of coders who only know the Rails DSL and don't even realize there is a distinct, not-Web-only language underneath, and I think that's a real shame given how great a language Ruby is. This isn't a 100% true thing, of course -- look at the CLI and server related tools that have come out of Ruby over the last few years -- but it still grates that every Ruby discussion is full of folks e.g. assuming you have ActiveSupport installed, or pointing you to Rails plugins for X when you wanted a generic solution for X instead. By comparison, in the Python world, only the newbiest of newbies confuse Django for Python, and even though Django does bring a number of new Python coders into the fold, it doesn't dominate the landscape like Rails does.
|
# ? Jun 18, 2011 06:33 |
|
It seems like a nice problem to have.
|
# ? Jun 18, 2011 07:52 |
|
code:
Jam2 fucked around with this message at 08:26 on Jun 19, 2011 |
# ? Jun 18, 2011 22:54 |
|
Soup in a Bag posted:Read up on Hash.new in the core docs. If you give the Hash a default object or block, that object will be used or that block evaluated whenever you reference a non-existent key. This needs further explanation because it's really confusing when you start programming ruby: code:
code:
code:
code:
|
# ? Jun 19, 2011 05:50 |
|
Pardot posted:It seems like your rails did not actually get updated to 3 for whatever reason. Also I'm assuming you're still using the ruby that came with osx, so while you're taking the time to get up to date and all that, you should Thanks a lot! Managed to get it running now.
|
# ? Jun 19, 2011 06:38 |
|
Jam2 posted:
It's the second argument to String#[]: quote:If a Regexp is supplied, the matching portion of str is returned. If a numeric or name parameter follows the regular expression, that component of the MatchData is returned instead. xtal fucked around with this message at 08:44 on Jun 19, 2011 |
# ? Jun 19, 2011 08:42 |
|
What's the best way to handle file uploads these days in Rails 3? I want to be able to upload a ZIP file, unpack it, then do stuff with the contents.
|
# ? Jun 19, 2011 20:15 |
|
I've used paperclip reliably for many months now, but CarrierWave is an up and coming gem that is supposed to be good. I haven't tried CarrierWave, but will recommend paperclip--it just works. If you're going to be hosted on Heroku and dealing with files >5mb you'll need to use a direct to s3 uploader like this fork of s3-swf-upload because Heroku will kill any long processes like a paperclip upload. I've worked with rubyzip for on the fly compression and had no complaints about it.
|
# ? Jun 19, 2011 20:24 |
|
atastypie posted:I've used paperclip reliably for many months now, but CarrierWave is an up and coming gem that is supposed to be good. I haven't tried CarrierWave, but will recommend paperclip--it just works. If you're going to be hosted on Heroku and dealing with files >5mb you'll need to use a direct to s3 uploader like this fork of s3-swf-upload because Heroku will kill any long processes like a paperclip upload. It's not so much of the process getting killed (I've had workers go for 16+ hours, though I really don't recommend that), direct to s3 is a better idea no matter where you're hosted because it won't tie up a web processes preventing requests while something is uploading. I've seen ways to get around that by having nginx or apache handele the upload and not your app, but they always seemed like a lot more effort than the direct to s3 things.
|
# ? Jun 19, 2011 20:30 |
|
atastypie posted:I've used paperclip reliably for many months now, but CarrierWave is an up and coming gem that is supposed to be good. I haven't tried CarrierWave, but will recommend paperclip--it just works. If you're going to be hosted on Heroku and dealing with files >5mb you'll need to use a direct to s3 uploader like this fork of s3-swf-upload because Heroku will kill any long processes like a paperclip upload. So what I'm trying to do is bulk upload a bunch of photos to the server and have them processed into S3 anyway, so I had already been starting to skeleton out some Paperclip-based models. This S3 uploader looks nice. Trying to get my head wrapped around his example as far as using this with Paperclip though. He's moving a file within the S3 bucket... Is the filename he's getting at line 39 here referring to the Paperclip derived path? And presumably he'd have declared a "has_attached_file :file" somewhere in the upload model, although it's not seen here? So if I did this, then I'd just have to move the upload out of wherever I staged it to, and then if I wanted thumbnails generated I'd just have to schedule a call to "reprocess!" in a background worker task?
|
# ? Jun 20, 2011 03:31 |
|
Pardot posted:It's not so much of the process getting killed (I've had workers go for 16+ hours, though I really don't recommend that), direct to s3 is a better idea no matter where you're hosted because it won't tie up a web processes preventing requests while something is uploading. I just assumed that it was the process getting killed because uploads using the paperclip defaults (upload to heroku -> process images -> upload to s3) will time out/fail on the first step if the file size gets too large. kitten smoothie posted:He's moving a file within the S3 bucket... Is the filename he's getting at line 39 here referring to the Paperclip derived path? And presumably he'd have declared a "has_attached_file :file" somewhere in the upload model, although it's not seen here? So if I did this, then I'd just have to move the upload out of wherever I staged it to, and then if I wanted thumbnails generated I'd just have to schedule a call to "reprocess!" in a background worker task? Yes, that's right. I'm not too crazy about s3-swf-upload and have been trying to implement other solutions, but not much else seems to exist. The only way I know how to do a direct to s3 and tie into paperclip is using js postbacks like in that example. You'll see he uses a <%= notification_of_file_uploaded_path %> or similar path name--that needs to be the route that ties to the described s3_upload action.
|
# ? Jun 21, 2011 15:59 |
|
Am I the only one using apache/passenger to host rails apps on their own? After seeing the S3 failure, I'm surprised to still see so much support for EC2/heroku here.
|
# ? Jun 22, 2011 00:20 |
|
It's a huge, huge pain in the rear end to deal with it yourself. Deployment can suck, you have to manage the security of the server, deal with scaling, contracting out data center space or some sort of hosting company, manage redundancy. The EC2 thing was a fluke, services were down but they came back up and everything is running. So you can either micromanage a whole ton of poo poo yourself, hire someone to do it full time, or you can 'git push heroku master' and be done with it. If you need to scale you can log into the web interface and move some sliders around and now you've scaled more.
|
# ? Jun 22, 2011 01:05 |
|
Cock Democracy posted:Am I the only one using apache/passenger to host rails apps on their own? After seeing the S3 failure, I'm surprised to still see so much support for EC2/heroku here. edit: Oh yeah, it is definitely a pain in the rear end to keep everything in-sync and up-to-date, etc. Especially when you create a dev/staging/production setup and want to keep all the Apache configs in sync. Git Pusshuten was neat but built entirely around Ubuntu which is not my server OS of choice. Obsurveyor fucked around with this message at 02:33 on Jun 22, 2011 |
# ? Jun 22, 2011 02:07 |
|
I use a managed VPS through Speedyrails so I get the flexibility of an Apache/Passenger setup without all the hassle.
|
# ? Jun 22, 2011 04:30 |
|
I'm starting to use OmniAuth. If I'm understanding correctly, it only connects with the Facebook API when a user needs to be authorized. Can I pull data from a user's facebook profile at will with OmniAuth? (I'm working from Ryan Bates' set of OmniAuth Railscasts here.)
|
# ? Jun 23, 2011 02:33 |
|
Trying to get 3.1 running on dreamhost. Shoot me.
|
# ? Jun 23, 2011 15:23 |
|
Dreamhost, pfft. You haven't truly lived in hell until you've tried to get any version running on Hostgator. I've been putting off a job for my dad for three days because I know it will again culminate in an hour of trying to determine why it's causing a server error for no apparent reason.
|
# ? Jun 23, 2011 17:43 |
|
Molten Llama posted:Dreamhost, pfft. You haven't truly lived in hell until you've tried to get any version running on Hostgator. This concerns me, because I have a client who wants to deploy on Hostgator later this summer.
|
# ? Jun 23, 2011 18:09 |
|
smug forum rear end in a top hat posted:I'm starting to use OmniAuth. If I'm understanding correctly, it only connects with the Facebook API when a user needs to be authorized. Can I pull data from a user's facebook profile at will with OmniAuth? In my experience, no you can't, but you do get a bunch of data back from facebook when they authenticate which you could save and process later.
|
# ? Jun 23, 2011 19:27 |
|
smug forum rear end in a top hat posted:I'm starting to use OmniAuth. If I'm understanding correctly, it only connects with the Facebook API when a user needs to be authorized. Can I pull data from a user's facebook profile at will with OmniAuth? You send a request to Facebook to access a user's account on his behalf. Facebook asks the user if that's cool. If the user says OK you get back a token and a secret to use later to access the user's info. OmniAuth handles negotiating with Facebook and gets the user token/secret for you. It's then on you to use those credentials (in conjunction with your application's key and secret) to actually access the data. There are lots of Facebook gems out there to handle the heavy lifting for you.
|
# ? Jun 23, 2011 19:39 |
|
What are some ways of issuing a shell command from a rails app and showing the user the output? For example, I'd have a list of network interfaces on the server, and you could click on button to turn the interface on/off, send a ping, or release/renew the DHCP address. These would just issue commands or run scripts I have written. There's be some sort of indicator icon in the same row as the interface icon that told the status, but I'd like some sort of box that displays the output from that script or command for more information.
|
# ? Jun 24, 2011 01:25 |
|
Kernel.system Be very, very, very careful with this.
|
# ? Jun 24, 2011 02:08 |
|
NotShadowStar posted:Kernel.system Or `command`, which conveniently evaluates to the stdout of the command.
|
# ? Jun 24, 2011 02:52 |
|
|
# ? May 14, 2024 10:48 |
|
You really, really, really don't want to execute shell commands from a script that accepts user-supplied data. I also doubt that you'd want to be able up/down a network interface or change its IP address via a web application.
|
# ? Jun 24, 2011 04:18 |