|
Plastic Jesus posted:What's the correct RESTful way to do a site-wide search? That is, the search itself will cover multiple models and I'm not quite sure what the "right" route is. Should it just be application#search? That seems strange. For a generic search, I'd probably make the controller "Searches" or "SiteSearch", talking to a "SiteSearch" model that handles interaction with ThinkingShinx or whatever engine you end up using.
|
# ¿ Feb 16, 2011 17:48 |
|
|
# ¿ Apr 23, 2024 11:51 |
|
Plastic Jesus posted:I created a controller and view for search, but I don't see why it needs a model. I could be wrong about this, as I'm usually wrong about these things. Putting logic in a model (models don't have to be ActiveRecord::Base children; they can be a plain old object too) means you can unit test it easier. Searches and fancy queries are a good example, because sometimes (especially pre-arel) there's a bunch of logic used to filter, sort, and join on different columns. You want to be able to test all this stuff and make sure it works without having to pick apart HTML to see if it did the right thing.
|
# ¿ Feb 17, 2011 08:03 |
|
Bob Morales posted:Ideally I'd like one new post controller and have it decide things based on what I pass to it, I guess I just don't know how to pass it. code:
You should probably split it up into the TopicsController and PostsController, and even if a Topic is just a Post with no parent, I'd be tempted to make a Topic model just so you can have a nice place for all the topic-finding methods.
|
# ¿ Mar 7, 2011 18:33 |
|
Obsurveyor posted:I am about at my breaking point with using Devise. You might not want to hear this, but ripping Devise out of a project that used it was one of the best things I've ever done for productivity.
|
# ¿ Mar 17, 2011 06:41 |
|
A MIRACLE posted:Thanks. Is there a reason the changes I make on a views/ file take some time to propagate (as opposed to showing the results instantly)? Are you editing on the live server running in production mode? If so, don't do that; edit locally in development mode, use version control, and a deployment tool. PHP amateur hour poo poo doesn't fly in Rails.
|
# ¿ Mar 17, 2011 06:42 |
|
8ender posted:I ended up creating a temp directory in my rails public folder, creating a file for export, writing the xlsx and streaming it with send_file, then using FileUtils to manually delete it afterwards. Its a kludge but it works. If you're using send_file, you probably don't need to put it in $APP/public/, you could get away with $APP/tmp or /tmp/application_name. If generating the xlsx is a slow task and you're not on Heroku or Windows, I'd probably use resque to move the xlsx generation out of the web request.
|
# ¿ Mar 18, 2011 18:51 |
|
rugbert posted:Can you use multiple accounts on heroku from the same computer? I dont like the idea of hosting a bunch of client sites on my heroku account. Sometimes I want to just push it off on them after Im done building so I dont have to deal with them anymore. Make a new account for the client site, grant your account permissions. As part of the client handoff, make sure they log in, change and document the credentials, and remove your permissions.
|
# ¿ Mar 23, 2011 01:46 |
|
Obsurveyor posted:Does anyone understand how before_filters work in Rails 3? I have been struggling with trying to secure js/json access to my app using the auth filters I already have setup to avoid code duplication. before_filter is supposed to be an alias for append_before_filter which implies that it is not messing with filters created beforehand, thus the word "append". However, if you do something like: Why are you trying to run the same before_filter multiple times? code:
|
# ¿ Mar 26, 2011 16:18 |
|
Obsurveyor posted:The actual filter would not run multiple times in a real scenario, that was just to show the Rails behavior. This is exactly what I wanted to do earlier: But answering the question you asked instead of the question you should be asking, this is passable I guess: code:
|
# ¿ Mar 26, 2011 23:14 |
|
rugbert posted:Ok I made a new account to test this out. Where can I grant my account permissions? I guess what I need to do is create an app on the new account, and then give my account the ability to collaborate? Is there a way to do that from my computer? Because my computer is tied to my account, should I use a VM? code:
|
# ¿ Mar 26, 2011 23:44 |
|
plasticbugs posted:Thanks for your help! I'm reading up on memoization right now. If you're on Rails 3 (or are otherwise pulling in activesupport 3), you can get a bunch of exrta tools (cache flushing, priming, for free by using the Memoizable module: code:
|
# ¿ Mar 30, 2011 18:51 |
|
rugbert posted:Awesome thanks, Im not seeing anything for another issue Im having where it takes a minute for my app to load so Im assuming thats normal. Yeah, Heroku doesn't run every app all the time, they're spawned on demand.
|
# ¿ Apr 1, 2011 14:33 |
|
jetviper21 posted:This is also the easy way and non elegant way. code:
code:
|
# ¿ Apr 2, 2011 04:50 |
|
skidooer posted:Good advice, but you'll want to put that in a lambda, otherwise Time.now will be evaluated when the model loads and will not increment with the clock. Good call, but your tests should cover that
|
# ¿ Apr 2, 2011 05:29 |
|
NotShadowStar posted:Nope, and actually you shouldn't be using scopes anyway. I think that post is based on some allergy to the same-line lambda syntax. That they're still in 3.1, not throwing a deprecation warning, shorter, easier to read, and easier to test is a good indicator that they're still a best practice. The lambda-vs-method-call thing is a bit of a red herring; the block isn't run for every record in the set, it's run once to build the association. I'd rather lose microbenchmarks and have declarative scopes than the reverse.
|
# ¿ Apr 2, 2011 19:52 |
|
NotShadowStar posted:I still don't understand what the point of this is. The only use-case that I see is 37s has cross-app dependencies, so that makes it easy. Most people don't have this, so the Passenger Preference Pane is just fine. I think it's just that making a symlink is less work than firing up the prefpane, waiting for it to restart in 32-bit mode, typing a password, and dragging a folder in.
|
# ¿ Apr 12, 2011 13:43 |
|
NotShadowStar posted:That's some serious first world problem. Every problem in software and computing is a first world problem, and "just fine" isn't when "fantastic" is available and free.
|
# ¿ Apr 12, 2011 16:54 |
|
plasticbugs posted:Thanks for the tips. I did want to obfuscate the Message ID somehow and I probably will soon to avoid the expensive lookup by message_url operation. If it's indexed in the database it shouldn't be expensive. If you still want to have something obfuscated but that doesn't look like you're just incrementing, can I recommend https://github.com/bkerley/have-code ? It probably works just fine with ActiveRecord 3.
|
# ¿ Apr 18, 2011 15:47 |
|
plasticbugs posted:One more question popped up. I want to limit users to creating 5 total items. Items belong to Users. The best way to do that seems to be to make a ActiveModel::Validator class inside the Item: code:
|
# ¿ Apr 21, 2011 02:40 |
|
Nolgthorn posted:I love Haml and Sass, to the extent that I think that support should be implemented natively in all browsers. Whenever I don't get to use Haml or Sass I find myself annoyed, like I need to cross a stream but before I do I'm told that I am not allowed to use the big piece of plywood that has been laid down over the stream for me to cross with. HAML and SASS are fine the way they are, and unless you have to be observed hand-writing invalid HTML for a class project or something, you can use them on static site projects just fine. CoffeeScript is even better than HAML & SASS just because JavaScript is more powerful and has more space to be annoying.
|
# ¿ Apr 24, 2011 15:56 |
|
Nolgthorn posted:When you say Haml and Sass can be used for static site projects, you still have to compile those pages. The big benefit is I can set my editor to run rake on save, or run rake output:push to build and publish the pages in one quick step.
|
# ¿ Apr 25, 2011 19:53 |
|
skidooer posted:I look forward to the day the browser is just a virtual machine and the HTML engine is a downloadable component. Do you want to have the security history, compatibility, and accessibility of ActiveX, Flash, or Java applets? Much of the web stack is focused on providing a way to incrementally implement tools that use it, and any replacements or improvements to it will be just as modular and easy-to-implement.
|
# ¿ Apr 26, 2011 02:59 |
|
Bob Morales posted:The problem is there's a few hundred a day so they get ignored, unless they start repeating. And they're probably things that should be fixed anyway. But they might as well be 'warnings'. So quit being a baby about it: every morning, pick one, write a test, fix it, deploy it.
|
# ¿ May 3, 2011 19:40 |
|
Trabisnikof posted:Yeah, I have no idea how to get my shop to use tests. So quit and go somewhere that does it right. There's a huge demand for Rails developers who want to do things the right way.
|
# ¿ May 3, 2011 20:21 |
|
NotShadowStar posted:Where oh god I want to leave the midwest frozen wasteland where people can't stop using PHP PM me if you're serious, at least one of my friends is looking for Rails people in Miami; they don't pay for relocation but here's a sample of our January weather:
|
# ¿ May 3, 2011 22:08 |
|
I worked in a shop like that, where the pressure to deploy anything at all was interfering with my ability to make quality software. I went to the management and said, "my last day is in two weeks," and haven't looked back. If they won't let you make quality software, they deserve what they get, and you don't deserve to get stuck with it.
|
# ¿ May 4, 2011 14:19 |
|
8ender posted:also this: https://github.com/thoughtbot/high_voltage I use that just because I can use markdown embedded in haml to make my static pages: code:
|
# ¿ May 9, 2011 22:45 |
|
NotShadowStar posted:Also, if some of your application errors are coming from Google trawling through your site and hitting AJAX only URLs, your AJAX setup is probably incorrect. Essentially you want the inverse of what this document tells you to do. I'd bet he's using the link_to :remote stuff.
|
# ¿ May 10, 2011 03:59 |
|
Anybody going to RailsConf this week? I'll be at the free Bohconf track Wednesday and Thursday.
|
# ¿ May 17, 2011 04:31 |
|
enki42 posted:I'm there now. Tutorial day was a little dull, looking forward to the keynote today. You should head over to the GitHub meetup on Wednesday, we'll have a beer. Cool! I'm bonzoesc on Twitter if you have it.
|
# ¿ May 18, 2011 01:02 |
|
I made a thing. It plugs into a Rack application on Ruby 1.9.2 and allows you to browse the source. For Rails 3: Add gem 'cans' to your Gemfile. Add mount Cans::Application.new, :at=>'/cans' to your config/routes.rb Browse to /cans/browser for the pretty backbone.js-based browser. Browse to /cans/ for the less pretty HTML-only views. Source is at http://github.com/bkerley/cans
|
# ¿ May 22, 2011 19:41 |
|
Pardot posted:That's cool. Were you inspired by seaside? If not, check out Seaside. The presentation I made for lightning talks at Rubyconf 2010 actually had a screenshot from Squeak in it
|
# ¿ May 25, 2011 05:51 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
|
# ¿ Apr 23, 2024 11:51 |
|
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 |