|
Son, I taught myself x86 assembly by reading disassembled executables. I'll manage. (Also I messed around in PHP for a bit and there is no way I'm going back to using that abomiation)
|
# ? Jun 1, 2011 13:46 |
|
|
# ? May 4, 2024 00:14 |
|
NotShadowStar posted:Step away from Rails for a while. Rails assumes you are an expert already, so if you're not you're likely going to be very, very lost. Especially with all the crazy abstraction poo poo 3.1 is going to do. From what I've seen, the model side of things isn't changing much, and it's still the best place (unless you need to use Concerns) to put your important business logic; reusable from queue workers or ActionMailer receivers, easy to unit test, and you can make raw objects to control processes that don't have a single-table data store (i.e. a HtmlSession model to encapsulate the authentication process for a web-browser consumer). If you just remember that ActionController is a fancy DSL, views are literally a whole new language that runs inside the controller, and that models don't need to be ActiveRecord you'll do fine.
|
# ? Jun 1, 2011 21:19 |
|
I have a quick association question. My image model is polymorphic so I can use it for 3 different things: employee bios(has_one), client bios(has_one), and blog entries(has many) I cant get the bios to work tho, whenever I try to upload an image I get unknown attribute errors. code:
code:
|
# ? Jun 2, 2011 01:10 |
|
rugbert posted:I cant get the bios to work tho, whenever I try to upload an image I get unknown attribute errors. Do you have the stack trace for this? Are you calling a_bio.file or a_bio.image.file ?
|
# ? Jun 2, 2011 16:24 |
|
BonzoESC posted:Do you have the stack trace for this? Are you calling a_bio.file or a_bio.image.file ? Heres the application trace code:
And here is my form code:
|
# ? Jun 3, 2011 00:15 |
|
rugbert posted:Heres the application trace The file_field should be in a fields_for block, as per http://apidock.com/rails/ActionView/Helpers/FormHelper/fields_for . It's trying to set @client.file, and you want it going to @client.image.file.
|
# ? Jun 3, 2011 03:57 |
|
Ahhh gotcha, that worked. Now when Im try to view with:code:
|
# ? Jun 3, 2011 19:20 |
|
rugbert posted:Ahhh gotcha, that worked. Now when Im try to view with: Because a ClientBio doesn't have a file method? Should you be calling f.object.image.file.url perhaps? Three dots in an invocation is too many anyways, so you should probably wrap that in a method on whatever f is, and write tests for it to make sure there's a sane fallback if there's no clientbio, image, or file. Cocoa Crispies fucked around with this message at 19:38 on Jun 3, 2011 |
# ? Jun 3, 2011 19:36 |
|
BonzoESC posted:Because a ClientBio doesn't have a file method? Should you be calling f.object.image.file.url perhaps? OH gotcha. Yea, I think that OOP class I took last semester just finally kicked in when I read that. Thanks! On another note - is there a way to exclude a path from a route? I have this route code:
ah gently caress you know what, matching that route on just about fucks everything up. I was hoping to build a CMS where users could make their own site sections and poo poo but I dont see how thats going to work out now. rugbert fucked around with this message at 03:43 on Jun 6, 2011 |
# ? Jun 6, 2011 03:35 |
|
rugbert posted:OH gotcha. Yea, I think that OOP class I took last semester just finally kicked in when I read that. Thanks! Did you read any of the comments in the routes.rb file?
|
# ? Jun 6, 2011 14:08 |
|
BonzoESC posted:Did you read any of the comments in the routes.rb file? I dont think it really helped, what I did find however was an old project I worked on with this company a few months back. Looks like I can loop through a model in my routes file and have routes created dynamically: [code] Section.all.each do |section| match "/#{section.name}" => "index#section", :as => "#{section.name}" [code/] Pretty cool.
|
# ? Jun 6, 2011 15:16 |
|
rugbert posted:I dont think it really helped, what I did find however was an old project I worked on with this company a few months back. Looks like I can loop through a model in my routes file and have routes created dynamically: code:
|
# ? Jun 6, 2011 15:21 |
|
BonzoESC posted:Please don't do that; you'll have to restart your app every time someone makes a new Section. Oh awesome, that makes everything and more a lot easier. Thanks! On something else altogether. When I use group_by{blah blah blah} to group a query in my controller, does it produce an array of records? Im trying to paginate the groups and not the records but I cant seem to get it to work.
|
# ? Jun 8, 2011 05:16 |
|
Hi folks, I have a quick question that I am sure someone can tell me the answer to. Please bear with me, I am very very new to web programming and as such probably look pretty dumb with this. I have a web service that is producing a JSON file for me for a faculty directory mobile app I am creating using Ruby. My question is given the following format of my JSON output, how would I go about displaying each element on the page? Here is my exact JSON format: { class: "LNameResponse class is here" - people: [ - { + class: "FacPerson class is here" + email: "personsemailishere" + firstName: "firstnameishere" + lastName: "lastnameishere" + phoneNumber: "phonenumberishere" + streetLine1: "address1ishere" + streetLine2: "address2ishere" + streetLine3: "address3ishere" }, - { + class: "FacPerson class is here" + email: "personsemailishere" + firstName: "firstnameishere" + lastName: "lastnameishere" + phoneNumber: "phonenumberishere" + streetLine1: "address1ishere" + streetLine2: "address2ishere" + streetLine3: "address3ishere" } ] } I am basically getting this back except add another 3-4 people in the people array. I can verify through my log file that the JSON is being returned from the web service and the values are correct. What I would like is to display this information in my view for each person in the people array one at a time. I know how to loop through and do this but everytime I try to access the people array I get a nil:nilclass error. Not sure what to do, any help would be appreciated. And sorry if this just sounds like sheer and complete jibberish, I am not too good at explaining problems sometimes.
|
# ? Jun 8, 2011 20:16 |
|
I need to learn Rails in a month, coming from a PHP background. What is the best book to buy?
|
# ? Jun 8, 2011 21:26 |
|
revmoo posted:I need to learn Rails in a month, coming from a PHP background. What is the best book to buy?
|
# ? Jun 8, 2011 21:37 |
|
revmoo posted:I need to learn Rails in a month, coming from a PHP background. What is the best book to buy? I thought this was pretty helpful: http://www.amazon.com/Beginning-Rails-Experts-Voice-Development/dp/1430224339/ref=sr_1_2?ie=UTF8&qid=1307572811&sr=8-2
|
# ? Jun 8, 2011 23:40 |
|
I started with the Poignant guide to Ruby and then moved to Agile Development with Rails and it was an easy transition from Java.
|
# ? Jun 9, 2011 00:25 |
|
Bosnian! posted:Hi folks, I have a quick question that I am sure someone can tell me the answer to. Please bear with me, I am very very new to web programming and as such probably look pretty dumb with this. I have a web service that is producing a JSON file for me for a faculty directory mobile app I am creating using Ruby. My question is given the following format of my JSON output, how would I go about displaying each element on the page? Here is my exact JSON format: So you're getting "JSON" that uses pluses and minuses instead of commas? What's the output from the JSON parser you're using (you can see and play with this non-destructively using the rails console).
|
# ? Jun 9, 2011 16:23 |
|
I'm at my wits end, or maybe I'm too tired. This is my first time using carrierwave, and for some reason I am having a hell of a time getting lightwindow to work correctly with it. (or any lightbox for that matter) code:
How can I remove the trailing /, or is there a better solution for my lightbox needs? Edit: Figured it out. The lightwindow plugin must be depreciated. Oh My Science fucked around with this message at 08:35 on Jun 10, 2011 |
# ? Jun 10, 2011 08:03 |
|
Oh My Science posted:How can I remove the trailing /, or is there a better solution for my lightbox needs? code:
|
# ? Jun 10, 2011 13:32 |
|
Pardot posted:mayhaps if you still want to use that plugin. Thanks, but I decided to go with topup since it seems to have better documentation. I have a new problem now, and it's about using kaminari for pagination. My app is basically a simple photo gallery, and although I have pagination working for the gallery index method, I need to limit how many images are displayed using the show method as well. It looks like this. code:
I can provide more code if necessary.
|
# ? Jun 10, 2011 22:06 |
|
Oh My Science posted:Thanks, but I decided to go with topup since it seems to have better documentation. code:
|
# ? Jun 11, 2011 16:17 |
|
Argh, I still don't get it. Here is some more information, hopefully someone can show me what I am doing wrong. controller : code:
code:
code:
How would I use kaminari to paginate the photos in the show view?
|
# ? Jun 12, 2011 00:19 |
|
Oh My Science posted:How would I use kaminari to paginate the photos in the show view? code:
|
# ? Jun 12, 2011 00:50 |
|
Obsurveyor posted:
Nope, I have tried many variations to no avail. Edit: loving got it. Thanks for the help. Oh My Science fucked around with this message at 01:21 on Jun 12, 2011 |
# ? Jun 12, 2011 00:55 |
|
Oh My Science posted:
Did you forget params[:pagina]? Also, thanks for using Ruby 1.9
|
# ? Jun 12, 2011 03:41 |
|
BonzoESC posted:Did you forget params[:pagina]? Yup I think that was the problem. I wish the documentation was more clear about that.
|
# ? Jun 12, 2011 03:45 |
|
Super basic question. What's the problem with this code? code:
|
# ? Jun 12, 2011 04:39 |
|
Jam2 posted:Super basic question. With yours you could do this code:
code:
|
# ? Jun 12, 2011 04:45 |
|
I see alot of dislike for Devise here, what do people use instead? Roll their own?
|
# ? Jun 12, 2011 10:13 |
|
Pardot posted:
|
# ? Jun 12, 2011 15:41 |
|
Jam2 posted:Would you mind explaining this a bit more? self refers to your Numeric class in that context, so it's perfectly OK to do what Pardot was suggesting. inside of class Numeric, the following two blocks of code are identical: code:
code:
smug forum asshole fucked around with this message at 16:16 on Jun 12, 2011 |
# ? Jun 12, 2011 16:10 |
|
smug forum rear end in a top hat posted:self refers to your Numeric class in that context, so it's perfectly OK to do what Pardot was suggesting. code:
|
# ? Jun 12, 2011 17:03 |
|
NotShadowStar posted:
Does this technique produce any "class instance variable"-style quirks in subclasses, or is it just a regular class method?
|
# ? Jun 12, 2011 17:35 |
|
hepatizon posted:Does this technique produce any "class instance variable"-style quirks in subclasses, or is it just a regular class method? They're just regular class methods, it's just a nicer way to define several in a row. Also I held off posting about it, waiting for someone else to do it first, but has anyone tried the new cedar stack yet? It's really cool, but I don't want to go on and on about it for fear it'd end up sounding like a sales pitch.
|
# ? Jun 12, 2011 19:01 |
|
NotShadowStar posted:When you understand class << self and can explain it in your own words, you've hit master level Ruby and win the game. I apologize if this comes across as dense. Is the << operator being used as append in this case? I'm reading a Ruby book and come across some this: The Ruby Programming Language posted:Many of Ruby's operators are implemented as methods, and classes can define (or redefine) these methods however they want. (They can't define completely new operators, however; there is only a fixed set of recognized operators.) As examples, notice that the + and * operators behave differently for integers and strings. And you can define these operators any way you want in your own classes. The << operator is another good example. The integer classes Fixnum and Bignum use this operator for the bitwise left-shift operation, following the C programming language. At the same time (following C++), other classes—such as strings, arrays, and streams—use this operator for an append operation. If you create a new class that can have values appended to it in some way, it is a very good idea to define <<.
|
# ? Jun 12, 2011 20:12 |
|
Jam2 posted:I apologize if this comes across as dense. Is the << operator being used as append in this case? It is not append in this case. It's getting at the metaclass. code:
|
# ? Jun 12, 2011 21:06 |
|
If you don't get the intracies of the difference between def self.method_name and class << self; def method_name don't worry about it at all. Like I said this is PhD level Ruby and in almost all instances you don't care about the difference; and if you do care about the difference then you should take a hard look at what you're doing because it's probably too convoluted.
|
# ? Jun 12, 2011 23:31 |
|
|
# ? May 4, 2024 00:14 |
|
Thanks for the explanation and link Pardot. Pardot, are you using a plugin to get the #=> output at the end of each line of code? I googled up the irb_rocket extension, and it looks like what I want. Pardot's post has me thinking: I sometimes wish I knew more about IRB. Anyone have opinions/suggestions on configuration or plugins to use to extend it?
|
# ? Jun 12, 2011 23:50 |