|
rugbert posted:how doe reject work? Ahh, undocumented rails "gotcha". You can't call any of your columns 'type', it's an inherent ruby property. Take a look at what you get when you actually run "p.type" in the console. As a side note, if you're just trying to filter the models, you should be applying the predicate as part of the conditions given to the database. Doing a PageContent.all.reject hydrates all the objects first then throws a bunch of them out. If you're rails 2.3.9 land: @pages = PageContent.all :conditions => "content_type != 'BlogPost'"
|
# ? Jan 16, 2011 02:28 |
|
|
# ? May 14, 2024 07:29 |
|
Hammertime posted:Ahh, undocumented rails "gotcha". You can't call any of your columns 'type', it's an inherent ruby property. Take a look at what you get when you actually run "p.type" in the console. I was taught to use type so that I could have inherited models. So I have a PageContent model and then I have a BlogPost model inheriting from it and I needed to have they type field to make it work. Which is does, but in this case I want to reject all BlogPost entries. Also Im using rails 3
|
# ? Jan 16, 2011 16:02 |
|
rugbert posted:I was taught to use type so that I could have inherited models. So I have a PageContent model and then I have a BlogPost model inheriting from it and I needed to have they type field to make it work. Which is does, but in this case I want to reject all BlogPost entries. Try doing the equivalent query that Hammertime suggested but with rails 3 syntax: code:
code:
|
# ? Jan 17, 2011 06:50 |
|
drjrock_obgyn posted:Try doing the equivalent query that Hammertime suggested but with rails 3 syntax: Oh cool thanks. That did it. So about heroku, Ive noticed that when Im using s3 and paperclip to upload images everytime I push new changes all of my uploaded images break. Is there a specific way I should set up my model? Right now I have:" code:
|
# ? Jan 17, 2011 16:48 |
|
rugbert posted:Oh cool thanks. That did it. You're telling paperclip to use the options for local storage there so it's probably not getting symlinked on each deploy (which you don't want to use with Heroku anyway). Have a look at the rdoc for the s3 storage and adjust the parameters accordingly: http://rdoc.info/github/thoughtbot/paperclip/master/Paperclip/Storage/S3.
|
# ? Jan 18, 2011 06:53 |
|
Any recommendations on where to start with choosing an authentication library for Rails 3 that will utilize existing database columns? Unfortunately, there is simply no way I can re-write everything I have in PHP for the new website I am working on in the time I have. That means I need to pull usernames and passwords from my existing CRM database. I do not need fancy features such as password reminders, resets, roles, etc. I just need something that will block page access based on logged in/not logged in and one other flag about the user's company in the database.
|
# ? Jan 19, 2011 15:11 |
|
Obsurveyor posted:Any recommendations on where to start with choosing an authentication library for Rails 3 that will utilize existing database columns? For simple needs like that you probably don't need a full blown library, just roll your own. And by rolling your own I just mean creating controller that checks a username and password and sets a session var with the user_id, and maybe a helper method that returns the user object from that session id.
|
# ? Jan 19, 2011 18:02 |
|
Anveo posted:For simple needs like that you probably don't need a full blown library, just roll your own. And by rolling your own I just mean creating controller that checks a username and password and sets a session var with the user_id, and maybe a helper method that returns the user object from that session id. Absolutely not. You will get it wrong an it will have holes Just use Devise. It's a granular as you want it to be and very simple to set up.
|
# ? Jan 19, 2011 18:23 |
|
NotShadowStar posted:Just use Devise. It's a granular as you want it to be and very simple to set up.
|
# ? Jan 19, 2011 19:06 |
|
.
maskenfreiheit fucked around with this message at 21:32 on Apr 28, 2019 |
# ? Jan 19, 2011 20:14 |
|
code:
|
# ? Jan 19, 2011 20:25 |
|
.
maskenfreiheit fucked around with this message at 21:32 on Apr 28, 2019 |
# ? Jan 19, 2011 21:46 |
|
.
maskenfreiheit fucked around with this message at 21:32 on Apr 28, 2019 |
# ? Jan 19, 2011 21:46 |
|
Check this page: http://nokogiri.org/tutorials/parsing_an_html_xml_document.html There's no variable called table_string defined anywhere. It's expecting table_string to contain something, like this: code:
If you put a URL in there, that URL isn't magically going to be parsed either. It's going to try and run an XPath query against the string "http://www.goatse.fr/" instead, and won't print anything because your XPath query returns no TR nodes to iterate through. However, the open-uri module gives you a dead simple way to pull a document in: code:
code:
|
# ? Jan 19, 2011 22:13 |
|
Obsurveyor posted:I wish Devise had actual documentation. Having an unsearchable wiki on github filled with a bunch of extremely specific howtos and no introduction to the API is classic. There appears to be nothing on how to add Devise to an existing rails app(rake devise:setup would not be wholly appropriate for me, with the legacy database involved). It just makes me want to look elsewhere for something better documented. http://railscasts.com/episodes/209-introducing-devise http://railscasts.com/episodes/210-customizing-devise You may also try Omniauth, but I have no experience with it. Devise and Warden have been battle tested http://railscasts.com/episodes/241-simple-omniauth
|
# ? Jan 19, 2011 22:28 |
|
Edit: Grrrrrrrrrr...nevermind, fixed it. Problem was NoScript. Plastic Jesus fucked around with this message at 23:12 on Jan 19, 2011 |
# ? Jan 19, 2011 23:03 |
|
NotShadowStar posted:http://railscasts.com/episodes/209-introducing-devise Oh good, screencasts. I love using Ruby, but it seriously irks me that the community's idea of "documentation" is one of: read a simple-rear end Hello World style README, pay money for a book, watch a (sometimes for-pay, almost always limited in scope) video, or learn the source code inside and out. Heaven forbid the author take the time to write some comprehensive usage + API documentation so non-trivial non-common use cases aren't left out in the cold. One of these days the Ruby and Python communities should switch places for a bit so Python can learn how to have usable test frameworks and Ruby can learn how to document their projects. I'm not bitter, who's bitter?
|
# ? Jan 19, 2011 23:24 |
|
I LIKE screencasts Especially Railscasts, they're very well done. Show, don't tell. Most documentation is awful anywhere you go. Most of the time with Ruby code, all you need is the basic idea and the RDoc. Ruby code is mostly self-documenting unless it's loving horrible, then nobody uses it. Now, if you want to talk about 'give us money because our poo poo is so hosed you can't figure it out', I'm getting into Drupal and holy gently caress. It's like they took acid hits on mars and designed some sort of hosed information system in PHP and completely didn't care about documenting it.
|
# ? Jan 20, 2011 00:03 |
|
bitprophet posted:I love using Ruby, but it seriously irks me that the community's idea of "documentation" is one of: read a simple-rear end Hello World style README, pay money for a book, watch a (sometimes for-pay, almost always limited in scope) video, or learn the source code inside and out. Thanks for the links NotShadowStar, I will be reviewing the asciicasts at work tomorrow. I think I have put together everything I need to use Devise and work with my legacy databases for the time being.
|
# ? Jan 20, 2011 00:07 |
|
NotShadowStar posted:I LIKE screencasts Especially Railscasts, they're very well done. Show, don't tell. I'm sure they're well executed (I actually don't watch very many and probably should check out more), I just would much rather search or skim text documentation than watch an hour long video in the vain hope that the info I need is at the 45 minute mark And aren't most screencasts just a glorified README? Or do some of them actually go in-depth? quote:Most of the time with Ruby code, all you need is the basic idea and the RDoc. Ruby code is mostly self-documenting unless it's loving horrible, then nobody uses it. Eh, many Ruby projects link to an RDoc with a bare skeleton of actual information (as in, great, I can see that X class has foo, bar and baz methods, but none of them actually have any documentation, just the function signature) and call it a day. Especially recently when some very nice doc oriented tools like YARD exist, there's just no excuse not to flesh out your API content and throw in at least a few pages' worth of prose docs explaining the relationship between the classes. quote:Now, if you want to talk about 'give us money because our poo poo is so hosed you can't figure it out', I'm getting into Drupal and holy gently caress. See also Magento, EZPublish, and probably every other huge PHP project It's true, I'd much rather wade through Ruby source code to figure something out, than use PHP -- but I still shouldn't have to. As mentioned, though, nothing is perfect. Python spoils me on documentation and so I get frustrated trying to put Ruby stuff together on a deadline; and when I'm working in Python using basic JUnit-style unit tests, I look back at rspec/cucumber/etc and cry a little.
|
# ? Jan 20, 2011 01:45 |
|
So I have a model, FloorPlan that has_many images. Can I use will_paginate to paginate just those images? my controller just has @floorplan = FloorPlan.find(params[:id]) and the view is a loop: code:
|
# ? Jan 20, 2011 17:47 |
|
Ugh. A client of ours wants to do adhoc excel based data reports with our software. My experience is that this feature is always requested buy rarely actually used. Oh well. Does anyone know of a good gem to make this less painful?
|
# ? Jan 20, 2011 18:33 |
|
Does it HAVE to be .xls? Usually I've had good success with just doing .csv and making sure the column headings are there, Excel imports it fine, just one extra click after opening it.
|
# ? Jan 20, 2011 21:19 |
|
rugbert posted:So I have a model, FloorPlan that has_many images. Can I use will_paginate to paginate just those images? Will_paginate is exceedingly easy to use. it's just @floorplan.images.paginate(:page => params[:page]).... what did you think you needed to do? Probably one of the best gems out there.
|
# ? Jan 20, 2011 21:48 |
|
I want to use the Linked In gem, but my app also uses Omniauth. Omniauth requires a newer version of oauth than the Linked In gem specifies, and Linked In specifies an exact version rather than '>='. This is easy to fix locally, but it'll break when I push to Heroku since Heroku will download the linkedin gem. Is there any clean way to supply a gemfile when pushing to Heroku?
|
# ? Jan 21, 2011 01:05 |
|
Anyone know the proper way to unit test a Rails initializer? Specifically, a custom decryptor for Devise? I know how to test it but I have no idea how you get at initializers with a test. I put it in a controller test but that feels really, really dirty.
|
# ? Jan 21, 2011 02:09 |
|
Plastic Jesus posted:I want to use the Linked In gem, but my app also uses Omniauth. Omniauth requires a newer version of oauth than the Linked In gem specifies, and Linked In specifies an exact version rather than '>='. This is easy to fix locally, but it'll break when I push to Heroku since Heroku will download the linkedin gem. Is there any clean way to supply a gemfile when pushing to Heroku? I had the exact same problem, and fixed it locally and forked the linked in gem and pointed it to my own git repository. You can use mine if you like: code:
code:
|
# ? Jan 21, 2011 13:14 |
bitprophet posted:Oh good, screencasts. Uhh, if you had gone to any of the Railscasts pages, you would see that every one has a complete transcript located on ASCIIcasts: http://asciicasts.com/episodes/209-introducing-devise
|
|
# ? Jan 21, 2011 14:38 |
|
NotShadowStar posted:Does it HAVE to be .xls? Usually I've had good success with just doing .csv and making sure the column headings are there, Excel imports it fine, just one extra click after opening it. Well no, CSV is fine actually. The main part, which I know is going to be a time vortex for our developers, is the adhoc "click all these dropdowns to get the data the way you want" part. Its also the part that in my experience no one ever ends up using. I may just push back and go for canned reports. Excel is better at massaging flat data than we'll ever be.
|
# ? Jan 21, 2011 15:59 |
|
HIERARCHY OF WEEDZ posted:Uhh, if you had gone to any of the Railscasts pages, you would see that every one has a complete transcript located on ASCIIcasts: http://asciicasts.com/episodes/209-introducing-devise Where did I say I was doing Rails work? (Yea, I know, it's technically a Rails thread...but it's not like there's a regular Ruby thread or I'd post in there. Another one of my beefs...Ruby the language is way too overshadowed by Rails.) Good to know that there are sometimes transcripts, anyway. I'll keep an eye out for such offerings next time I find myself looking at screencasts. bitprophet fucked around with this message at 19:11 on Jan 21, 2011 |
# ? Jan 21, 2011 16:40 |
|
To be fair people were doing wacky as hell things to the syntax and structure of the Ruby language until ActiveRecord and ActiveSupport. I maintain the LDAP library and holy crap, Ruby code from 2003-2004 is bizarre. Then after Rails people started doing wacky as hell things to the metaprogramming aspect of Ruby mirroring Rails, but the structure was nicer. Then Yehuda Katz and Sam Ruby came in and kicked all the wacky metaprogramming out and now everything is
|
# ? Jan 21, 2011 16:52 |
|
NotShadowStar posted:To be fair people were doing wacky as hell things to the syntax and structure of the Ruby language until ActiveRecord and ActiveSupport. I maintain the LDAP library and holy crap, Ruby code from 2003-2004 is bizarre. I love Yehuda, he's awesome. (He's also not ashamed to look at what Python and Django did right and to steal ideas, which is cool. And Rails 3 struck me as sort of a Rails version of Django's 2006-2007 "magic-removal" upheaval.) And I'm not saying that Rails is bad or that its influence on Ruby has not been a net positive; just that as a not-usually-Rails dev using Ruby, it's frustrating that everything out there (blog posts, documentation, the way stuff is packaged, answers to questions etc) often assumes a Rails context.
|
# ? Jan 21, 2011 19:14 |
|
enki42 posted:I had the exact same problem, and fixed it locally and forked the linked in gem and pointed it to my own git repository. You can use mine if you like: Thanks for this. I have no clue why it didn't occur to me to use github but it didn't. Wait, right, it's because I'ma deeply stupid man.
|
# ? Jan 22, 2011 02:09 |
|
Ok, so I thought I had this figured out (in my head) but I need some help. If I have a model say, Drawing and it belongs_to :user and each User has_one :drawing how would I set it up so when a user logs in, he only see's his drawings and no one else's? All I can think of off hand is to add a user_id to all drawings and have the controller look for all drawings where user_id == current_user.id (Im using devise). Whats the best way to tackle this or whats a good tutorial for scenarios like this?
|
# ? Jan 22, 2011 19:10 |
|
code:
|
# ? Jan 22, 2011 19:20 |
|
NotShadowStar posted:
ok so what that does is grabs a user's ID and then uses that ID to find the corresponding drawing. When and how do I use that tho? In the controller? Like @drawings = u.drawings.all? Could I use devise's current_user to get the drawings like current_user.drawings? Sorry, Im just started to get deeper into RoR but I havent had a hell of a lot of time so Im learning as I go.
|
# ? Jan 22, 2011 21:06 |
|
You really should learn the fundamentals of ActiveRecord associations, because this is really basic stuff. http://guides.rubyonrails.org/association_basics.html
|
# ? Jan 22, 2011 22:44 |
|
I'm doing my first rails project and I'm wondering if there is a best practice for admin interfaces? From my research it seems that I can go with namespaces or with dual-use controllers and views. With namespaces I have to make two controllers with their respective views and in each I have 95% of identical code. If I go without namespaces I have my views all cluttered up by <%= if current_user.admin? %> and inserted admin functionality. Neither seems very appealing to me.
|
# ? Jan 23, 2011 10:50 |
|
Triggerle posted:If I go without namespaces I have my views all cluttered up by <%= if current_user.admin? %> and inserted admin functionality. code:
|
# ? Jan 23, 2011 18:34 |
|
|
# ? May 14, 2024 07:29 |
|
Triggerle posted:With namespaces I have to make two controllers with their respective views and in each I have 95% of identical code. If I go without namespaces I have my views all cluttered up by <%= if current_user.admin? %> and inserted admin functionality. I went with namespaces across three projects and I haven't regretted it. My experience with admin stuff is that although there are going to be times (in views in particular) when you're duplicating some things its worth it in the long run to have the flexibility to do something completely different for the admin without putting logic everywhere and hoping there isn't some edge case you're missing thats exposing that to regular users. I've even got a namespace for the "manager" interface in one of our apps because its so fundamentally different from the regular way employees access the same data.
|
# ? Jan 24, 2011 14:58 |