|
True, I'm getting this error: "undefined method `entries' for main:Object" line starting with "with_options" and the one right below it. With this code: code:
|
# ¿ Dec 23, 2008 05:23 |
|
|
# ¿ May 15, 2024 23:39 |
|
Well I'll be, that works. Incredible that it does, confuses me a lot. Thanks. Edit: also I was able to cram my map.root in there too. code:
Nolgthorn fucked around with this message at 05:33 on Dec 23, 2008 |
# ¿ Dec 23, 2008 05:30 |
|
Fairly certain that attachment_fu still doesn't support cropping due to the vast differences between the many image processors out there. You may have a modified version of the plugin that is only designed to work with some processors and may be running on a different one by default in production. Try this: code:
|
# ¿ Dec 26, 2008 04:13 |
|
Pardot posted:This is by far the best article on Rails 3 Merb/Rails merge, or Why should merbists be happy?, and it's answered all of the questions I had about what was in it for merb. Why is it important to maintain any semblance of plugin backwards-compatibility? Generally if you're developing a Rails application, you use the latest version and go to production when it's done using whatever version you started with, unless there is a feature you absolutely need you wouldn't update it. I would imagine there is a lot of code that could be different or that is different in Merb, why keep all these old methods? Isn't that all the opposite of trimming down the bloat Rails has been accumulating and the opposite of making it run faster? Edit: Ohhh they're just talking about a public API for plugin functionality... ok I guess. I really hope they bring Merb's slices. Nolgthorn fucked around with this message at 11:29 on Dec 26, 2008 |
# ¿ Dec 26, 2008 11:16 |
|
I still think you would benefit by specifying the image processor you want if you're going to be using cropping.
|
# ¿ Dec 26, 2008 15:17 |
|
Is there a way to easily report at the bottom of the page on a development application the processing time, requests and speed of which the page loaded? I am getting tired of always looking over to my terminal window on every page request to see even just a summary of what's been happening. Also another question; I understand that the development environment runs a bit differently than in production. Now that I've got my db requests more or less optimized for the time being I'm noticing that my bottleneck seems to be loading partials, for instance I am using a commenting system and each comment is a partial with another partial in it for the rating system. When there are 25 comments being loaded on the page each one loads at a speed of between 0.7-1.7ms for the rating and 1-3ms per comment, in comparison the full amount of db requests on such a complex page load maybe 0.3ms in absolute total. Why are the partials being loaded slowly, in production are these partials just going to be in memory or something? Thanks in advance for both questions Nolgthorn fucked around with this message at 01:50 on Dec 29, 2008 |
# ¿ Dec 29, 2008 01:48 |
|
Thanks you guys for your help. I have another question that might be really simple. Is there a way I can update a column in the database on a table that contains a field named updated_on, without having the updated_on field update? In the old days it was possible to do: code:
Edit: It seems that I cannot even hack my way around it, here is my fat controller code: code:
I may need to call the column something different if I want to have more control over it I guess. Nolgthorn fucked around with this message at 12:05 on Dec 29, 2008 |
# ¿ Dec 29, 2008 11:48 |
|
I am being honest when I say that is some of the ugliest code I have written... sigh the Internet and posting things I will regret. The code would look a lot cleaner if 'they' at Rails core would get associated objects built all in one request, that way I could easily tuck the params[:first_post] inside of params[:forum_thread][:comment] and be done with the whole thing. I did try putting some logic in my model for this along the lines of: code:
I have since renamed the offending column like you guys have mentioned, I don't fully know what I was thinking... something seems simple and I get further along then it's no longer any good for my purposes. I am however going to maintain that && is more or less exactly the same as 'and' for me generally because I only ever use 'if' or 'unless' statements with booleans. Nolgthorn fucked around with this message at 17:32 on Dec 29, 2008 |
# ¿ Dec 29, 2008 17:25 |
|
Exactly, except that it would do something once it hit the .new(params) method.
|
# ¿ Dec 29, 2008 17:33 |
|
I too don't like the way field_error_proc adds that horrible div around failing form elements, it's always messing up my layouts. I usually make it a point to add this at the very end of my environment.rb: code:
Edit: As a related question is there a way to reliably return error messages on the fields from an associated model, then display them or what is the best practice for this? Nolgthorn fucked around with this message at 15:20 on Dec 31, 2008 |
# ¿ Dec 31, 2008 14:46 |
|
Usually I use paragraph tags around my form elements, then I have things on the right of it or maybe I've got a field in the middle of a sentence for some reason I dunno stuff gets messed up. True I could use display inline on the divs but why not use span though, it's nice to have the control.
|
# ¿ Dec 31, 2008 18:14 |
|
Panic! at the Fist Jab posted:Is anyone using edge Rails and the latest featureset that Rails provides consistently? I stopped using Rails about a year ago and focused on microframeworks like Sinatra, and I'm wondering if there's anything really amazing that I'm missing that the switch to Rails may be worth it again. Any awesome plugins, etc... No not really, I am really looking forward to Rails 3 they promise to merge Merb and hopefully we get nice little things like recursive database manipulation.
|
# ¿ Jan 10, 2009 13:48 |
|
Sewer Adventure posted:How can I expire a cache from a model? expire_fragment only works in controllers. The best idea is to use sweepers and set them up to expire the cache when the model performs certain actions. At least that's what everyone will tell you in order not to break MVC. Alternatively you can just explicitly call the method you need using something like this: code:
|
# ¿ Feb 1, 2009 21:27 |
|
I've been playing around with Authlogic for my new application. It seems to me it is very nice. For some reason it doesn't have a great grasp of telling me what is best for my database while using it. For instance, the suggestion on the site offers migrations which include :null => false on just about every single field and things like :default => "" etc, but not in all examples. Why are things like this so prevalent in so many gems and plugin tutorials out there? Personally I prefer to handle all of that "is-it-blank?" validation stuff in the model, if it gets by the model I probably planned on it going into the database not being rejected for some reason after it gets there or being replaced with "" instead of being null. The other thing it seems to not be mentioning is to add indexes to any of the database fields, is this common practice too? I would think for logging in purposes things like the login field should be indexed. What about all of those <blank>_token fields? Those should be indexed too... I'm always so confused when I hit the migrations portion of any tutorial because they still seem to not do things the way I do them. Is there a benefit to not indexing fields and is there a benefit to adding restrictions or defaults to the fields in a clean database? Edit: Besides setting a boolean field to default false or a <blank>_count field to 0... Also doesn't setting a default on a field in migrations negate the :null => false assignment anyway? Nolgthorn fucked around with this message at 07:29 on Feb 16, 2009 |
# ¿ Feb 16, 2009 07:10 |
|
Trabisnikof posted:In other news Passenger is awesome, but first load is slow. Sports at 11. It still doesn't get us past using god drat horrible awful terrible capistrano though, which is my biggest grief, so it's useless to me until that day which I'm dreaming of.
|
# ¿ Feb 19, 2009 23:32 |
|
I've always felt after being tutored on and using capistrano that it is far too complex for something as simple as a rails deployment. I can perform deployments faster with less issues just using a SFTP client of my choosing. Really, capistrano is unnecessary all you need is to move the files onto the server, perform some rights management on the files create a symlink and that's it. This could all probably be done extremely easily with a bash script. Instead capistrano comes lumbering in with it's billions of lines of code and complete absurdity to "do it for me" which is crap too since I have to go out of my way to tell it not to do things that break the deployment if left alone. I don't even fully grasp the benefit of a server side huge ton bunch of file changes and history of the application, but even that is handled by svn not capistrano. Capistrano is a big piece of crap. <>
|
# ¿ Feb 20, 2009 01:50 |
|
savetheclocktower posted:Ah, how sloppy of me. I think I was thinking of Markaby. There does seem to be a trend towards Ruby but Ruby is a really really good high level programming language.
|
# ¿ Feb 22, 2009 03:54 |
|
Drogadon posted:This week I got introduced to the wonders of HAML/SASS and was further blown away by Compass using the Blueprint CSS framework. I've just been working with this today! A few notes: Here is the guide I used to get up and running with compass and blueprintcss on Rails: http://github.com/chriseppstein/compass-rails-sample-application/blob/81ab7a654754e30f76560018c58b90d05e8200dd/README After that I wanted to vendor the gem, so I added these two lines to my environment.rb: code:
rake gems:unpack Bada bing bada bang boom! In addition I found that when trying to use +showgrid with this gem it was pointing to the grid.png image in the wrong place. I had to change the gem in <gem>/frameworks/blueprint/stylesheets/blueprint/modules/_debug.sass, line 1 and line 4. From: images/grid.png To: /images/grid.png Now everything works, I'm on Rails 2.2.2.
|
# ¿ Feb 23, 2009 03:50 |
|
That was just the problem with Capistrano, it WAS NOT A BIG PROJECT it was made big by the guy writing it when really all it had to be was really simple. I'm glad it's gone, I hope it never gets worked on again and I hope myself or someone else finally gets off their rear end and makes something good, like that "The Destroyer" thing which was posted. I hate Capistrano, through no personal or "emotional" response to the person who was building it, I just think that it is not useful and only gets used because people pile behind things regardless.
|
# ¿ Mar 1, 2009 11:31 |
|
Question; but good lord, let me try my best to explain it. I have a users table and a conversations table. I've constructed a conversation_users table to keep track of the last time a user visited a given conversation and some assorted other info that relates the two. What I want to do is eagerly load the information in this table depending on both which user is logged in and which conversations are currently being viewed. Right now my models simplified look like this: code:
What I'd ultimately like to do is add something like this to the Conversation model: code:
|
# ¿ Mar 12, 2009 12:23 |
|
I have moved things to the controller like you suggest and added an extra method to the model. Thank you for your help, I'm concerned though it will start to get a lot messier as the project advances forward. Here's what I've done: code:
Something tells me I'm not doing this the rails way and I'd like to, unless this is the rails way and I'm just confusing myself. Nolgthorn fucked around with this message at 23:00 on Mar 12, 2009 |
# ¿ Mar 12, 2009 22:47 |
|
that is what im doing. The problem is i want to eagerly load the table for items on the index, which isn't really a problem... just a concern that it's not the best way to do it. Thats all, and Im obviously doing something that isnt common after all so no worries.
|
# ¿ Mar 12, 2009 23:49 |
|
It isn't the owner... I think we're falling way off base here of what I've been trying to do, though skidooer's initial suggestion was good. Remember that the conversation_users table is there to keep track of the last time a user visited a given conversation and some assorted other info that relates the two. But I guess what I didn't clarify was that a record gets added or updated on this table once every time any user visits a conversation. There is one conversation_user record for each pairing of a conversation and a user, where the user has visited the conversation. The solution I am using based on Operation Atlas' first suggestion works, but I was aware that Active Record was capable of searching based on two indexes because I know of has_many through and I know of has_and_belongs_to_many... That's all I really wanted was to pair up the current user and a list of conversation objects then be able to eagerly load the conversation_user data for each conversation where available.
|
# ¿ Mar 14, 2009 00:27 |
|
That's what I'm already doing though. I really appreciate all the help with this but please start talking about something else guys. I'm already doing what people are suggesting which tells me that I'm already doing it the best way I can, or I'm doing it the way I should. Thanks to everyone though.
|
# ¿ Mar 14, 2009 05:14 |
|
Ok gently caress it, here's what I did instead. It's a tale of woe and sadness, a knight's frustration and suffering. Many castles have fallen, many people left a bitter wreck at the side of the road. The amount of complication that had arisen out of all this became too much for my little medieval brain to bear, you're just going to have to trust me that it started to get pretty crazy and all for what I kept asking myself. So I've exposed my current_user object to the model using cattr_accessor, which is something yes I know I am not supposed to do. code:
This is just so much off my mind. :knight:
|
# ¿ Mar 14, 2009 18:41 |
|
It feels like Rails 3 is just around the corner. I'm at a loss, I have a large project I want to get started on but I'm not sure if I should use the latest from the Rails 3 repository and then update as it goes or just use 2.3. I wonder if I will be able to more or less migrate my 2.3 app into a Rails 3 application later on.
|
# ¿ May 7, 2009 14:37 |
|
My concern was mostly that Rails 3 might be vastly different from 2.3. I would not be able to migrate a Rails app to a Merb app easily for instance, it would be more or less a rewrite. I guess I'll stick with Rails 2.3, you're right that it will still be supported for quite a while.
|
# ¿ May 7, 2009 17:22 |
|
Not really a question I just wanted to say the anticipation for Rails 3 release is killing me.
|
# ¿ Aug 4, 2009 18:18 |
|
I decided to use a unique name column to look up objects on one of my models. I want to be able to change this unique name.code:
code:
code:
Edit: hmm I suppose I could use something like this. code:
Nolgthorn fucked around with this message at 02:15 on Apr 3, 2010 |
# ¿ Apr 3, 2010 02:08 |
|
I really appreciate it NotShadowStar. But I've merely simplified all that stuff you wrote, so that it would be easier to answer my more specific question. I'm already using REST and standard restful controllers and error_messages_for and a form partial and those things. When validation fails, the page is refreshed. It doesn't really go to an entirely different page, the update action re-renders the edit page again. Even though a happy bright red message box does indeed appear the form's action parameter changes and points to an incorrect path based on the modified name field in the form. This is because the name field is used to render the model object as a parameter in my model. But I don't really know how to fix it. The best thing would be if I could pick and choose times that to_param renders as the name, or renders as a id. Nolgthorn fucked around with this message at 21:10 on Apr 3, 2010 |
# ¿ Apr 3, 2010 21:08 |
|
^^ This. Totally answers my question, it's genius! I totally forgot model_path() accepts strings, integers and the like... this'll only take a bit of changes.
|
# ¿ Apr 5, 2010 19:32 |
|
Hello. The solution may be just out of my reach... I've slept on it, woken up and still remain confused about how to solve it. :wall: I have three models :page, :chunk and :cut_text Chunk is a crazy model. It has two polymorphic associations :chunkable and :cutable :page is a :chunkable and :cut_text is a :cutable. :chunk is acting right now as sort of a habtm between :page and :cut_text. :cut_text and :chunk are both created at the same time when creating a :cut_text. :chunk contains a few nested attributes that appear on the :cut_text form. When creating a new :cut_text; 'accepts_nested_attributes_for :chunk' allows :chunk attributes to be applied to a new :chunk. I've added validation to :chunk which validates both :chunkable and :cutable have been applied. code:
It is necessary I specify '@cut_text.chunk.chunkable = @page' somewhere as to ensure the new nested :chunk object contains a :chunkable object and passes validation before @cut_text can be saved successfully. But the chunkable attribute is not accessible due to attr_accessible which is trying to prevent users from modifying the value. I cannot call update_attribute after the record exists as the record will never validate. How do I tell rails that it's ok to set the :chunkable attribute before saving the :chunk, while still using attr_accessible and validation?
|
# ¿ Apr 15, 2010 21:30 |
|
Operation Atlas posted:You can't. The solution is probably to just be careful in the controllers (setting the value in the hash yourself) and take out attr_accessible. I realized there is probably no reason to use validations on something that users cannot access. I chose to put the changes inside of a transaction ensuring both objects are accounted for. Nolgthorn fucked around with this message at 22:53 on Apr 17, 2010 |
# ¿ Apr 17, 2010 22:51 |
|
In the application I'm working on before showing things like last names, email addresses, etc. I have it set up so that privacy settings are assessed that ensure a user actually wants their email address or last name to be visible. The problem is that often a whole unnecessary query that traverses backwards through the user model from within the privacy model is run: "self.user". Is there a way to magically give the user object into the privacy model when I reference the privacy object so it doesn't have to traverse backwards? Having trouble solving this logic experiment, or else there is something very simple I just don't see! code:
code:
|
# ¿ Jul 3, 2010 19:04 |
|
Wow, thank you dark_panda. That is pretty much exactly what I was looking for, I can go back and clean up some of my code now. While Rails is using id columns to look up relational objects, the User object is exposed to my users through a different unique identifier. So the user objects weren't being retrieved by id most of the time, therefore are not getting cached. Is there a patch to make this whole inverse_of functionality on by default in the works currently? Is it memory expensive, too much bloat?
|
# ¿ Jul 5, 2010 19:16 |
|
plasticbugs posted:I had a column in my model named "Type". I've done this or similar a lot with Rails. One time it was a little obscure one and a problem didn't crop up with it until weeks later with some weird insane error on one specific specialized action. Now I use a thesaurus to pick most of my names. A couple of current favourites are: Crowd, Stream, Disclosure, Party, Participant, Actor, Candidate, Rival.
|
# ¿ Aug 25, 2010 21:21 |
|
I believe the current rails 3 auth favourite is devise. http://github.com/plataformatec/devise
|
# ¿ Aug 26, 2010 06:55 |
|
I assume since I have been using Rails (especially Rails 3) for a little while now that I am spoiled beyond repair with regard to ease of web application development. What I am looking for after having constructed a complicated application, is some way of analyzing and picking at what is being rendered into HTML for me. There are partials everywhere, coupled with helpers, coupled with information spread across lots of different database tables. There are several places where database information is being eagerly loaded and other places where the assumption is that the page information is cached etc. Are there any gems available that will sort of... make it easier to see exactly what is going on? The reading I have done has led me to believe I need to write performance based tests, but those don't really tell me everything I am hoping to more easily know. Maybe some kind of gem that monitors everything my application is doing and then creates a big beautiful page that details where all of the bottlenecks and rendering hogs are. Is there something like that? code:
|
# ¿ Nov 18, 2010 14:55 |
|
8ender posted:There is NewRelic: Interesting. Thank you for giving me a jump off point, I didn't realize that such a thing would be so expensive. The few automated options available seem to be fairly... well dishonest. I don't think that the software only being able to update data once every 10 minutes unless I upgrade to a much more expensive version is very accurately reflecting their costs for the service, for example. For these prices I feel like just using my brain, going through the code and reading logs manually instead.
|
# ¿ Nov 18, 2010 19:47 |
|
|
# ¿ May 15, 2024 23:39 |
|
Anveo posted:You can also just use it locally in development mode. Just browse a few pages and then go to /newrelic. It will at least give you more context than just eyeballing the code and logs. I'll try to keep you guys up to date on what my method ends up being, I'm going to try and avoid newrelic for now. It seems to be the go to application for my specific use request, but I'm feeling a little bit heretic. Thanks everyone for the advice, I really appreciate it. Serious.
|
# ¿ Nov 23, 2010 20:17 |