|
code:
|
# ? May 31, 2012 13:00 |
|
|
# ? May 15, 2024 02:10 |
|
Or the other way around if you already have the leaguecode:
|
# ? May 31, 2012 14:34 |
|
8ender posted:
For the most part, although I changed it as Player.find(params[:player_id]).leagues << League.find(params[:league_id]) This worked, however now I run into another problem where Rails is not pointing to the correct route when I just want to delete the player from the league and not the player itself. Here is my routes table code:
code:
|
# ? May 31, 2012 17:19 |
|
Strong Sauce posted:For the most part, although I changed it as Player.find(params[:player_id]).leagues << League.find(params[:league_id]) A Player, a League, and a player's Membership (just a suggestion) in a league are different concepts. Being able to name and manage this join relationship as an independent concept is why has_many through: is generally better than has_and_belongs_to_many. code:
|
# ? May 31, 2012 17:49 |
|
Yeah that's probably going to be the best solution. Still odd that Rails won't override the route though.
|
# ? May 31, 2012 18:03 |
|
Strong Sauce posted:Yeah that's probably going to be the best solution. Still odd that Rails won't override the route though. Routes don't "override" until they're evaluated at request time. When you DELETE that route, what action does it route to?
|
# ? May 31, 2012 18:15 |
|
BonzoESC posted:Routes don't "override" until they're evaluated at request time. When you DELETE that route, what action does it route to? When I say override, I meant I specify a different route in routes.rb. When I run rake routes it's suppose to generate what the proper routes should be, and it seems to duplicate the same route. The other route I overrode, "post 'leagues/:league_id/players/' => 'players#create_league_player'" right underneath the DELETE route doesn't show up subsequently down the route path. However the DELETE route still shows up when it's suppose to be overridden. Right now the route is still using ,"players#destroy" rather than "player#drop_from_league"
|
# ? May 31, 2012 18:37 |
|
Strong Sauce posted:When I say override, I meant I specify a different route in routes.rb. When I run rake routes it's suppose to generate what the proper routes should be, and it seems to duplicate the same route. The other route I overrode, "post 'leagues/:league_id/players/' => 'players#create_league_player'" right underneath the DELETE route doesn't show up subsequently down the route path. However the DELETE route still shows up when it's suppose to be overridden. Did you try moving your drop_from_league declaration below the resources? You can also suppress the default delete: http://guides.rubyonrails.org/routing.html#restricting-the-routes-created
|
# ? May 31, 2012 18:50 |
|
BonzoESC posted:Did you try moving your drop_from_league declaration below the resources? So moving it below the resources didn't work, but excluding destroy method works! Thanks! Still odd though.
|
# ? May 31, 2012 19:57 |
|
plasticbugs posted:Regarding Foreman: I answered my own question quoted above in case anyone's interested or it may help someone trying to solve the same problem. I added the guard-rspec gem to my app and I have a nice autotest setup now. I edited the Guardfile to include color output for rspec per this github comment . However, I could have also just run: foreman run rspec and gotten the same result, without installing Guard -- albeit without autotest. In any event, foreman run your_process_here is a good way to load in your .env variables and have them available to whatever process or rake task you want to run (like Rails console, rspec, etc.). Eg. foreman run rspec
|
# ? Jun 1, 2012 08:03 |
|
Hey, guys. I'm hoping someone here can assist me with a little Model association problem I have. I have two models: class User < Act... end class Playlist < Act... end There is a single user (the user who created it) who maintains executive control of the playlist. This is the owner. Furthermore, a playlist can be associated with many users (they all share and edit it at the discretion of the "owner") and a user can be associated with many playlists. Without the owner complexity, I would just use the has_many_and_belongs_to to link the two models. What's the best way to accomplish these associations?
|
# ? Jun 13, 2012 04:08 |
|
Off the top of my head:code:
|
# ? Jun 13, 2012 04:40 |
|
prom candy posted:Off the top of my head: Does playlist_subscriptions have to be a model? Does playlist end up with two has_many associations or is the first just necessary for the second "through" association?
|
# ? Jun 18, 2012 23:48 |
|
Check out the documentation on has_many :through, you can see it here under the "Many-to-Many" header: http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html
|
# ? Jun 19, 2012 18:57 |
|
Jam2 posted:Does playlist_subscriptions have to be a model? You want it to be a model; if it wasn't one, you'd have a hard time testing, describing, and reasoning about the relationship between playlists and users that are subscribers.
|
# ? Jun 19, 2012 20:51 |
|
It also makes it easier to add more information about the relationship, if ever you want to get fine grained about permissions, etc.
|
# ? Jun 20, 2012 00:36 |
|
I find myself wanting to Learn more about ruby, has anyone taken the ruby course from pragmatic studio? I could probably grab a book or two, but I'm partial to video tutorials.
|
# ? Jun 20, 2012 16:36 |
|
I began work today realizing that I need to leave. I've got a lot of experience and a few web application ideas and decided to look into Ruby more. After a few hours I ended up finding Poingnant's Guide. I love this thing, but it seems like it's focused on Ruby. Aside from the 'Hard Way to Code in Ruby', does anyone have any other books/tutorials?
|
# ? Jun 21, 2012 00:34 |
|
Oh My Science posted:I find myself wanting to Learn more about ruby, has anyone taken the ruby course from pragmatic studio? I could probably grab a book or two, but I'm partial to video tutorials. several of the people on my team have taken this course, and while some of it was remedial for them, even the ones that are coding daily and inside console all the time found it educational.
|
# ? Jun 21, 2012 01:04 |
|
Abel Wingnut posted:I began work today realizing that I need to leave. I've got a lot of experience and a few web application ideas and decided to look into Ruby more. After a few hours I ended up finding Poingnant's Guide. After you get through Learn Ruby the Hard Way, work your way through the Ruby koans to reinforce what you've learned. Michael Hartl's Ruby on Rails Tutorial was invaluable in helping me put all the pieces together with regards to Rails, testing, best practices and MVC. It's here. The Ruby on Rails Tutorial screencasts are worth every penny, but you can save some money by working your way through the book online for free. Also, even though they're a little out of date, the Peepcode Rails screencasts are very handy. I got a lot out of the Command Line ones. I recommend it if you're new to the command line. I also enjoyed the Git and Textmate screencasts.
|
# ? Jun 21, 2012 09:15 |
|
You might also check out Coursera's SaaS class. It's the free on-line version of UC Berkeley's SaaS course, and covers Ruby, Rails, test-driven development, and a couple of other things over six weeks. I didn't speak Ruby before I took it and thought it was a pretty good introduction to the language, and rails.
|
# ? Jun 21, 2012 23:30 |
|
Not Rails-related, but since we don't have a Ruby thread.. I am having a weird thing where a Ruby code:
edit: if I do it in irb it gives me the same error and then says "Maybe IRB bug!!" etcetera08 fucked around with this message at 18:58 on Jun 23, 2012 |
# ? Jun 23, 2012 18:56 |
|
etcetera08 posted:Not Rails-related, but since we don't have a Ruby thread.. I am having a weird thing where a Which versions of lastfm and dependency gems are you using? Usually when that error occurs it is some kind of infinite recursion problem but that probably won't help you solve this problem.
|
# ? Jun 23, 2012 19:17 |
|
Dangerllama posted:You might also check out Coursera's SaaS class. It's the free on-line version of UC Berkeley's SaaS course, and covers Ruby, Rails, test-driven development, and a couple of other things over six weeks. Thanks for this, ill be sure to check it out next. I ponied up for the pragmatic course and although it's not challenging me, I am relearning some basic fundamentals.
|
# ? Jun 23, 2012 21:01 |
|
etcetera08 posted:Not Rails-related, but since we don't have a Ruby thread.. I am having a weird thing where a Do you have another file in your load path named lastfm.rb that might be requiring the file with that line?
|
# ? Jun 23, 2012 22:08 |
|
What is the best choice for a templating system for something like an online choose your own adventure book? The writers would need to be able to access story wide variables. I was thinking something like Mustache.
|
# ? Jun 24, 2012 04:56 |
|
Strong Sauce posted:Which versions of lastfm and dependency gems are you using? Usually when that error occurs it is some kind of infinite recursion problem but that probably won't help you solve this problem. The Journey Fraternity posted:Do you have another file in your load path named lastfm.rb that might be requiring the file with that line? Hmmm, I'm thinking it might be an RVM problem. I'll try to clear everything out and reinstall. edit: yep, did a gem uninstall and then gem install and it seems to work now. Thanks guys.
|
# ? Jun 24, 2012 08:04 |
|
So I have a quick question regarding hosting. Yes I know about heroku and use it for most of my sites BUT what about high traffic sites? I made rtattoos.com that really doesnt get any traffic, but if any image is linked to reddit then ill get between 1K and 4K hits a day which isnt much but theyve taken the site down a couple times. Heroku can get kind of expensive so I was wondering if anyone had other suggestions? How does rackspace hold up?
|
# ? Jun 29, 2012 01:19 |
|
AWS is pretty well priced.
|
# ? Jun 29, 2012 02:15 |
|
Sinestro posted:AWS is pretty well priced. It totally depends on the use. At some point, a VPS or even a bigass machine colocated is better. If you have high IO requirements, VPS or Amazon might not be the best.
|
# ? Jun 29, 2012 02:34 |
|
AWS > Rackspace > Remote colo. But this very much depends on what you're trying to do. I've been a sysad for a dozen years or so, and these days I'd look to AWS for anything less than half a rack without extremely specific (read: "a metric fuckton" of IOPS) requirements. Amazon's EC2 and PaaS offerings are miles ahead of anything else out there. I presume you've looked at Elastic Beanstalk? waffle enthusiast fucked around with this message at 04:13 on Jun 29, 2012 |
# ? Jun 29, 2012 04:09 |
|
Here's a big wide question: Are you guys doing skinny controller fat model or are you doing skinny controller model as persistence layer and then lots of PORO for your actual business logic? Why/why not? Lately I've been moving my business logic out of my models and into Plain Old Ruby Objects because they're easier to test and because my models were getting insanely long on big projects. How are you guys handling big projects with Rails?
|
# ? Jun 29, 2012 05:58 |
|
prom candy posted:Lately I've been moving my business logic out of my models and into Plain Old Ruby Objects because they're easier to test and because my models were getting insanely long on big projects. How are you guys handling big projects with Rails? I'm interested to know this because the models in our largish app are just starting to feel a little overweight.
|
# ? Jun 29, 2012 06:59 |
|
8ender posted:I'm interested to know this because the models in our largish app are just starting to feel a little overweight. I've never worked on a particularly large Rails project, but I've read about other projects which refactor model behaviors into "concerns" using Ruby modules. Decent example here: http://blog.waxman.me/extending-your-models-in-rails-3
|
# ? Jun 29, 2012 07:18 |
|
That's not really refactoring though as much as just splitting up code into smaller files and including them. It's still really helpful when your models get huge, but there's starting to be a lot of people that say that anything not involving the persistence layer doesn't belong in the model. One example of this is a site that I'm working on right now that needs to build an Invoice out of data that's imported from a Job on another site. I moved all of the logic for importing into an InvoiceImporter class. It makes testing really easy because you can just use a mock for the actual Invoice instance and then make sure the right calls are going to it, and it also maintains Single Responsibility Principle. The class that's responsible for storing and fetching invoices from the database doesn't need to know about the logic behind creating one from a job. I'm interested in what other people are doing though, I've heard arguments towards continuing to keep a lot of logic in the model and it is sort of The Rails Way.
|
# ? Jun 29, 2012 14:21 |
|
prom candy posted:I'm interested in what other people are doing though, I've heard arguments towards continuing to keep a lot of logic in the model and it is sort of The Rails Way. This is sort of where we're at right now because we've been burned in the past by straying from "the way" when new versions of Rails come out. App concerns looks pretty good though and having official support in Rails3 is nice.
|
# ? Jun 29, 2012 16:26 |
|
prom candy posted:That's not really refactoring though as much as just splitting up code into smaller files and including them. It's still really helpful when your models get huge, but there's starting to be a lot of people that say that anything not involving the persistence layer doesn't belong in the model. I've been trying to follow this a bit as well, it certainly slims down the models a bit and improves SRP, makes testing easier, yadda yadda. Taking it to the extreme, some people will go so far as to only use AR models for persistence and then delegate all business logic to POROs. I haven't played around with this yet, but it seems harder to do in practice. There was a rubydrama earlier this week (or maybe last) when someone posted a pastie of their rails code after getting canned, and it followed some of these practices, and DHH was chiming in something along the lines of "just use before_filters in your controller" or something, without making a new class or anything. I'm not sure I agree that you should either put everything in the controller or everything in the model as methods, a little bit of OOP can go a long way in my experience. The trick is to not create a mess in the process. For some reading material, there's Practical Object Oriented Design in Ruby and also Objects on Rails (free). I like the O'Reilly book, and Avdi's book is decent but his coding style is a bit strange.
|
# ? Jun 29, 2012 16:27 |
|
Avdi's book is what got me thinking this way, and the Destroy All Software screencasts are pushing me further down that road. Sometimes I get the feeling that DHH enjoys his own dog food a little too much but I'm not going to pretend that I know better than him.
|
# ? Jun 29, 2012 17:12 |
|
I'm not sure where to begin with this one but I have a Rails app on Heroku right now that uses Devise for handling user authentication and I've got about 50 customers with accounts. I recently wrote a C# application and I'd like to implement some sort of authentication before users can start running this app. Is there any way I can make the Rails app communicate with the C# app? I know this is possible with Microsoft SQL Server and IIS but I'd really just love to send a request to the postgres database on Heroku for validation or use some other technique that allows me to query the Rails app for user login info.
Tomed2000 fucked around with this message at 04:32 on Jul 6, 2012 |
# ? Jul 6, 2012 04:18 |
|
|
# ? May 15, 2024 02:10 |
Tomed2000 posted:I'm not sure where to begin with this one but I have a Rails app on Heroku right now that uses Devise for handling user authentication and I've got about 50 customers with accounts. I recently wrote a C# application and I'd like to implement some sort of authentication before users can start running this app. Is there any way I can make the Rails app communicate with the C# app? I know this is possible with Microsoft SQL Server and IIS but I'd really just love to send a request to the postgres database on Heroku for validation or use some other technique that allows me to query the Rails app for user login info. Well, you can take advantage of Rails' RESTful api design. Submit a POST to the corresponding sessions controller (that handles logins) and specify in the headers that you want a json formatted response of some kind. XML would work too I suppose. Then parse the results when they come back from the server in your C# code. It's really late and I've been coding all day so I might have missed something but that seems like the most straightforward way to do it.
|
|
# ? Jul 6, 2012 04:44 |