Bob Morales posted:Gotcha. In this particular case they'd want ALL the evaluations for the promotion so I'm not sure why they would put 0-99. Ugh. 99 is a pretty big number they'd probably never need to go higher than that.
|
|
# ? Aug 10, 2011 21:57 |
|
|
# ? May 14, 2024 13:59 |
|
A MIRACLE posted:99 is a pretty big number they'd probably never need to go higher than that. Also no one will ever need the first one, 0.
|
# ? Aug 10, 2011 22:06 |
|
Bob Morales posted:Gotcha. In this particular case they'd want ALL the evaluations for the promotion so I'm not sure why they would put 0-99. Ugh. Because they have no idea what they're doing, but they think they do. http://guides.rubyonrails.org/active_record_querying.html#retrieving-multiple-objects-in-batches
|
# ? Aug 10, 2011 23:03 |
|
What are your guys' recommendations for routing this: I have a members section where members can browse (index?), view (show), edit their profile, delete their account, and upload/manage images. I am however using devise which has already made a bunch of routes using /users so I was thinking I should namespace the members section. But if I do that then my routes are going to be crap like /members/users/edit/1 and /members/users/1/images/new where I would like them to be /members/edit/1 and members/images/new so Ive tried using this module thing I read about but that makes the root /users/editblabhalbh and then I tried using namespace and then modules but that does the same thing. edit - on a related note, why are some of my routes missing paths when I rake routes? code:
|
# ? Aug 11, 2011 16:12 |
|
rugbert posted:I have a members section where members can browse (index?), view (show), edit their profile, delete their account, and upload/manage images. Controllers have no knowledge of the model you're using; the scaffold controller naming is strictly convention. If you want a Members controller that interacts with User objects, there's nothing stopping you from making one. You can have a Members controller and a Users controller that interact with a User model in different ways. It's also transparent to the router. If you want REST and add a 'resources :members' to your routes.rb, it's just directing traffic to MembersController. (It'll make some REST fanatics blow a gasket because it's "wrong," but that's their problem.)
|
# ? Aug 11, 2011 20:59 |
|
Molten Llama posted:Controllers have no knowledge of the model you're using; the scaffold controller naming is strictly convention. If you want a Members controller that interacts with User objects, there's nothing stopping you from making one. You can have a Members controller and a Users controller that interact with a User model in different ways. Huh, in that case, if I wanted to nest my resources (members>images) I would just do code:
|
# ? Aug 11, 2011 21:53 |
|
rugbert posted:but how would I set the controller up for the members/images? code:
|
# ? Aug 11, 2011 21:59 |
|
rugbert posted:but how would I set the controller up for the members/images? Ive never nested my resources before? Im trying to set it up so each of my users has the ability to manage their own images. but I already have an image controller being used for something else, which is why I wanted to namespace it Set up the routes first, run rake routes, and see what controller it expects them to route to? (This is what I would try first, no idea if it works or not.)
|
# ? Aug 11, 2011 22:08 |
|
skidooer posted:You don't have to really do anything special. The routes will provide, in your case, a member_id parameter from the URL (/members/:member_id/images) which you can do stuff with. Otherwise, it is just like writing a controller without nesting. well I already have an image controller being used for something else (anonymous image submissions) and I need a separate controller for handling images by members. I guess I could make a second controller called "member_images" but its going to start looking gross. code:
code:
|
# ? Aug 11, 2011 23:29 |
|
rugbert posted:
It's okay to have multiple controllers that handle the same kind of resource, and it's okay to have routes that have path entries that aren't the controllers they route to.
|
# ? Aug 12, 2011 00:23 |
|
BonzoESC posted:It's okay to have multiple controllers that handle the same kind of resource
|
# ? Aug 12, 2011 07:37 |
|
skidooer posted:Though it is also okay to have a single controller handle the same kind of resource in different ways. Personally, unless the way member images are handled is wildly different, I would probably keep everything in the images controller. Of course it is hard to make any recommendations without having knowledge of the entire problem domain. I'd rather have multiple (thin) controllers manipulating the same (fat) models than a single controller with a poo poo-ton of conditional logic based on routes manipulating the model. If this results in a lot of duplication, you should probably refactor more of your business logic into the model.
|
# ? Aug 12, 2011 19:07 |
|
BonzoESC posted:I'd rather have multiple (thin) controllers manipulating the same (fat) models than a single controller with a poo poo-ton of conditional logic based on routes manipulating the model. code:
|
# ? Aug 12, 2011 19:22 |
|
And in any case, you should be using inherited resources and let it do all the dirty nested route lifting for you:code:
|
# ? Aug 12, 2011 20:50 |
|
Well Im still a noob so I have no idea what the last 3 posts meant. Anyway, what I decide to do was nest the images controller in with the members section and then use my index controller to handle the anonymous image submissions for non-members. So I have this: code:
I am running into an issue with my /submit page. It correctly uses the the index/new view but I get this error code:
code:
Also - I set up my member nested routes like so: code:
code:
whew, routing is fun rugbert fucked around with this message at 04:01 on Aug 14, 2011 |
# ? Aug 12, 2011 23:29 |
|
What would be a good (or bad) way to add users to a system service (say email, that uses a plaintext config file for user info) from a Rails web interface? So if someone signs up, they get added to /etc/passwd and have an shell account? Is there something really, really wrong with just doing 'exec adduser -whatever username'?
|
# ? Aug 14, 2011 19:43 |
|
Bob Morales posted:What would be a good (or bad) way to add users to a system service (say email, that uses a plaintext config file for user info) from a Rails web interface? So if someone signs up, they get added to /etc/passwd and have an shell account? Is there something really, really wrong with just doing 'exec adduser -whatever username'? Make sure you sanitize the gently caress out of their username
|
# ? Aug 14, 2011 19:50 |
|
Bob Morales posted:What would be a good (or bad) way to add users to a system service (say email, that uses a plaintext config file for user info) from a Rails web interface? So if someone signs up, they get added to /etc/passwd and have an shell account? Is there something really, really wrong with just doing 'exec adduser -whatever username'? Use LDAP, pam_ldap for system authentication and Net::LDAP in Ruby. Seems like overkill, but if you're screwing around with system authentication, you should use a battle tested service instead of rolling your own and invariably loving it up.
|
# ? Aug 14, 2011 21:03 |
|
NotShadowStar posted:Look at Padrino. How clean fresh tidy and snappy Padrino is. What is missing, that you guys are finding you use Rails instead?
|
# ? Aug 15, 2011 11:34 |
|
Quick question: I installed Ruby 1.9.2-p290 using RVM. But when I type "ruby -v" in terminal, it still says the version is 1.8.7, which is the default that OS X Lion ships with apparently. I assume this is because the Ruby that RVM installs is different fromt the one the operating system uses, or something. Could someone explain this for me? I'm relatively new to OS X (and terminal) - AND I am also learning Ruby and RoR, so the learning curve is a lot steeper...
|
# ? Aug 21, 2011 20:38 |
|
enraged_camel posted:Quick question: Type rvm use to see if rvm is being caught by bash, and what version it's set up to use. If it says it's using version 1.8.7, rvm list will show the other installed versions of ruby you can choose from If it doesn't recognize the rvm command, you might need to source ~/.profile -- you did add the line of code that rvm needs to be loaded into your shell session into your ~/.profile, didn't you?
|
# ? Aug 21, 2011 20:41 |
|
enraged_camel posted:Quick question: You need to set which version you are using. code:
Or if you want a book: Agile Web Development with Rails, 4th edition is a decent resource to walk you through learning it.
|
# ? Aug 21, 2011 20:46 |
|
smug forum rear end in a top hat posted:Type rvm use to see if rvm is being caught by bash, and what version it's set up to use. When I type rvm use, it says it's using 1.9.2. But why does ruby -v show 1.8.7? What's the difference between the rvm ruby version and the "system" ruby version? What is the latter used for? If I'm doing Ruby development, do I need to worry about this discrepancy? @Nybble: I already set 1.9.2 as the rvm default - thanks for the suggestion though. Also thanks for the links, I'll take a look.
|
# ? Aug 21, 2011 21:02 |
|
enraged_camel posted:When I type rvm use, it says it's using 1.9.2. Go ahead and type in that command anyway (rvm use 1.9.2), and then try ruby -v. If you still see 1.8.7, then there is an issue I'm not sure about. I'm just a few weeks ahead of you experience-wise, I just started learning myself, and those tutorials have been pretty helpful.
|
# ? Aug 21, 2011 21:12 |
|
enraged_camel posted:When I type rvm use, it says it's using 1.9.2. Your PATH probably isn't getting set properly for some reason. After you 'rvm use 1.9.2', it should get updated to give the rvm version priority, and look similar to this: code:
If you're using a system that's been repeatedly migrated/upgraded, you may be on tcsh and not know it. Molten Llama fucked around with this message at 01:06 on Aug 22, 2011 |
# ? Aug 22, 2011 01:01 |
|
Molten Llama posted:Your PATH probably isn't getting set properly for some reason. After you 'rvm use 1.9.2', it should get updated to give the rvm version priority, and look similar to this: While I can't speak for tcsh, I can 100% say that rvm works fine with zsh. Also unless you go out of your way to change it the default shell on os x is bash. (But using bash instead of zsh is like using mysql instead of postgres: poo poo) The rvm initialization lines for enraged_camel are probably just not being ran, either they aren't in his .whatever file, or the one he has it in isn't being ran.
|
# ? Aug 22, 2011 01:10 |
|
Pardot posted:While I can't speak for tcsh, I can 100% say that rvm works fine with zsh. Also unless you go out of your way to change it the default shell on os x is bash. (But using bash instead of zsh is like using mysql instead of postgres: poo poo) Good to know. I gave it a super quick try with zsh and tcsh and neither one updated with rvm environment changes (but rvm's probably out of date on this system, it may work with something newer than I've got). bash is the default shell on OS X today—until 10.3 it was tcsh, and depending how you've moved between releases and computers it's possible to still be on tcsh today. Unknowingly having the old school default bites longtime users on an occasional basis.
|
# ? Aug 22, 2011 02:11 |
|
Are there any good resources, free or otherwise, on making internal DSLs?
|
# ? Aug 22, 2011 02:33 |
|
Doc Hawkins posted:Are there any good resources, free or otherwise, on making internal DSLs? Have an example of what you want it to look like? There's several ways, including the Magic Pen style that I like.
|
# ? Aug 22, 2011 03:04 |
|
There's lots and lots of ways and styles. I'm not a fan of the old style redundant do |obj|; obj.something; obj.another_thing; that Rake, AR migrations and such do to a single object. Instead I prefer what you see in a Gemfile, FactoryGirl or Mongoid *theres a couple limitations on doing it that way that occasionally you need to do the do |something| syntax, so that's why we need to know what you're doing.
|
# ? Aug 22, 2011 03:58 |
|
So I get the idea that times stored in the DB are in UTC, and it's the app's responsibility to adjust for local timezones. I've set my timezone as Eastern in application.rb. My form uses a time_select. So I submit the form with a time of, say, 13:00. My understanding is that it should go into the database as 18:00 UTC (as EST is UTC-5), but it doesn't, it goes in as 13:00 UTC. Is there somewhere else I need to be compensating for this before I send it to the database? What am I doing wrong here? I had the types set in my schema as time instead of datetime. Changing that fixed it right up. Lamont Cranston fucked around with this message at 22:57 on Aug 22, 2011 |
# ? Aug 22, 2011 06:54 |
Rails noob here. Is there a "cleaner," less bulky way of extracting inner text XML with Nokogiri? Feel free to make fun of my awful code.code:
A MIRACLE fucked around with this message at 22:08 on Aug 22, 2011 |
|
# ? Aug 22, 2011 20:45 |
|
NotShadowStar posted:we need to know what you're doing. Well, at the risk of being outed as one of those "nerd" people: http://www.github.com/njay/tabletop It's one of those pointlessly ambitious geek proects: make it easier for people to make software tools for or versions of "pen and paper" games by making a DSL for them. Teach Yourself Ruby the Hard and Uncool Way. There's a lot more I want to do, but I thought that a survey of resources about the field might help me make decisions about what sort of things I should want to do.
|
# ? Aug 22, 2011 22:14 |
|
I don't see anything horrible but I cleaned it up slightly and made it a but more ruby-like. Don't be afraid to stack methods with ruby, you don't get the horrors of NullReferenceExceptions if something goes wrong like Java or C#.code:
|
# ? Aug 22, 2011 22:17 |
|
Doc Hawkins posted:Well, at the risk of being outed as one of those "nerd" people: http://www.github.com/njay/tabletop Your die language is scrub-tier: https://github.com/bkerley/crapshoot & https://github.com/bkerley/triskelion Mine's a Ragel-based implementation, so an external DSL. Use it online at http://triskelion.heroku.com/
|
# ? Aug 22, 2011 22:40 |
|
BonzoESC posted:Your die language is scrub-tier: That's...really cool. I like how terse it is, but I'm hoping to make something that's as natural-language as I can. The hope is that anyone who makes (or just likes) an RPG could figure out how to describe its rules and procedures with just a commands cheat-sheet and a few minutes thought. For that kind of purpose, I think that "drop_lowest" is kinder than "v". And also I need them to be able to do stuff like "tell me how many dice came up seven or higher, counting tens twice" or "count sets of die values, multiply the size of the largest set by ten, then add the value of the dice in that set" without needing to learn regular expressions. The results object extending Int is an inspired idea. I thought about making a separate results object for a while, but it seemed like there was too much state to track: you only really know when it's stopped being a "roll" and started being a "result" when the player stops interacting with it, so I just piled everything into the Roll class. If there's no good short-cuts to understanding, I will soldier on.
|
# ? Aug 23, 2011 06:49 |
|
Doc Hawkins posted:I like how terse it is, but I'm hoping to make something that's as natural-language as I can. The hope is that anyone who makes (or just likes) an RPG could figure out how to describe its rules and procedures with just a commands cheat-sheet and a few minutes thought. For that kind of purpose, I think that "drop_lowest" is kinder than "v". And also I need them to be able to do stuff like "tell me how many dice came up seven or higher, counting tens twice" or "count sets of die values, multiply the size of the largest set by ten, then add the value of the dice in that set" without needing to learn regular expressions. quote:The results object extending Int is an inspired idea. I thought about making a separate results object for a while, but it seemed like there was too much state to track: you only really know when it's stopped being a "roll" and started being a "result" when the player stops interacting with it, so I just piled everything into the Roll class. This goes back to requirements; originally (November 2010) rolling was handled inside the rails app with regexes, but I broke it out (December 2010) so I could play with parsers. Making the Result delegate on top of Integer (January 2011) is just a hack, since the API returning an Integer was already in place, and I didn't want to re-engineer everything to allow getting a description for a past roll. Your best bet for designing a DSL is to just write some poo poo with no implementation and see if you like it. If you do, figure out how to implement it. If not, try again. Here's a prototype DSL for a Twitter client framework that I never got around to making: code:
|
# ? Aug 23, 2011 17:28 |
|
Yeah, that's basically what I've done so far. BDD 4 lyffe. I guess was hoping there were articles that could give me some tips like "Be sure to consider factor X, which might not occur to you until you've wasted a lot of time doing something dumb!" But all I found was an article explaining how to use instance_eval to avoid "do |o| o.stuff end" syntax. I think I need to bring in some other stakeholders. Maybe I'll be able to harass some folks at PAX into doing a focus group.
|
# ? Aug 23, 2011 17:57 |
|
Doc Hawkins posted:Yeah, that's basically what I've done so far. BDD 4 lyffe. Would your DSL be useful for doing a D&D-style character sheet? code:
How about handling parameters for specific levels of classes? code:
Don't answer those yet! Get something simple (the 'Character' example above maybe?) working, worry about the rest later.
|
# ? Aug 23, 2011 18:56 |
|
|
# ? May 14, 2024 13:59 |
What are the differences between these?code:
|
|
# ? Aug 26, 2011 20:19 |