|
kayakyakr posted:I avoid confirmation emails because it kills conversion. Especially when you're trying to get less technical people to follow through. Ugh, the non-technicals. Exactly. Mandatory registration & confirmation emails are a death sentence in many business areas, like in e-commerce. And that's one area where you need real email address validation, and not a regex like /@/, because invalid email addresses and typos cause a non-trivial amount of support work. If you guys want a simple way to do it Right™, you can use a service like Mailgun's Email validation API to avoid most of the hard work. Smol fucked around with this message at 02:00 on Jul 29, 2013 |
# ? Jul 29, 2013 01:55 |
|
|
# ? May 15, 2024 04:17 |
|
Somehow Eclipse just knows where to find the info for content assist. I'm guessing it uses my rvm gem settings (I'm on windows) to figure out where the gem library is. I'd like to switch this to a different directory which resides on a network drive. Has anyone had experience with this?
|
# ? Jul 30, 2013 19:28 |
|
I have two models: Thread and Comment. They represent threads and posts in a typical forum - each thread has many comments, each comment belongs to a thread. I want to have a user create a new Thread by submitting a title for the thread, and some text for the content of the comment. Here is my ThreadController#create method: code:
|
# ? Jul 31, 2013 06:10 |
|
I'm assuming @my_thread is the same as @thread.code:
Maybe you can create the first comment in a before_create filter in the model before you allow it to save a Thread object, but I'm not sure how data passing would work. e. Might be a dumb question but why not just have a Comment model, with an Original Post column, and some Comments being flagged as OPs(and then treated as if they are threads). Is it ever the case that you want a thread without a comment? You can have objects of class Comment belong to other objects of class Comment unless google lies to me. Sil fucked around with this message at 07:00 on Jul 31, 2013 |
# ? Jul 31, 2013 06:54 |
|
Safe and Secure! posted:I have two models: Thread and Comment. They represent threads and posts in a typical forum - each thread has many comments, each comment belongs to a thread. Without going into the code and the design too far you can always check if my_thread.valid? and comment.valid? Then save both else render new
|
# ? Jul 31, 2013 07:08 |
|
Sil posted:e. Might be a dumb question but why not just have a Comment model, with an Original Post column, and some Comments being flagged as OPs(and then treated as if they are threads). Is it ever the case that you want a thread without a comment? You can have objects of class Comment belong to other objects of class Comment unless google lies to me. I don't really mind Threads not having Comments, but what I'd really like to avoid is Threads not having Comments due their Comments having been invalid at creation time. As for getting rid of Threads and only having Comments, wouldn't that waste space as I'd then have to add a "title" column to my Comments table, which would be non-null for only a small amount of Comments? tima posted:Without going into the code and the design too far you can always check if my_thread.valid? and comment.valid? Then save both else render new Ugh, I thought .valid? could only be run after one called .save, but rereading the documentation tells me that I'm wrong on that one. So yeah, as Sil suggested, I'll get rid of the Thread if it's invalid, except I won't even save it in the first, because as you said I can just call valid? first. Thanks!
|
# ? Jul 31, 2013 07:23 |
|
Safe and Secure! posted:I don't really mind Threads not having Comments, but what I'd really like to avoid is Threads not having Comments due their Comments having been invalid at creation time. Thinking about it some more I think just having Comments would make things more complicated. But I actually have no idea what the space effect would be. Keep in mind the OP would be a boolean column that's essentially 1 byte large(?) but associated with every column. On the other hand the Thread table can get pretty large as well, depending on the average comments/thread your app will have. I don't really know enough about Rails/SQL/anything to figure out at what comment/thread density one solution is more space efficient than the other. That being said, you might want to allow Threads to be bookmarked and comments not, you might not want to keep discussion flat(ie. can't comment on comments) etc. So there are other concerns to keep in mind if the Thread table is more than just an ID and some child comment pointers. fake edit. OH but postgresql (and all sql?) can do variable length columns, so your nulls take up no space. See http://stackoverflow.com/questions/5437336/postgres-performance-static-row-length Initial advice, probably bad. Curious google-journey that it spawned, pretty fun!
|
# ? Jul 31, 2013 08:49 |
|
You could also use accepts_nested_attributes_for, and then you don't have to manually build the Comment in your controller. If you want the Thread to ensure the comment is valid, use "validates_associated :comments" in Thread. Edit: Then again, validating all the comments of a giant thread is probably not the best idea. manero fucked around with this message at 14:27 on Jul 31, 2013 |
# ? Jul 31, 2013 13:46 |
|
manero posted:Edit: Then again, validating all the comments of a giant thread is probably not the best idea. But if it's just on thread create, it might not be too bad since there would only be 1 comment to validate.
|
# ? Jul 31, 2013 15:25 |
|
I have a form on which you can post an item, and when you do, I want to handle that post with AJAX and re-render the list of posts. I have my list of posts set up like this:code:
code:
|
# ? Aug 1, 2013 06:23 |
|
I'm about a two-year Perl dork that is wanting to goof with Ruby/Rails some. My first goal is going to be porting my police-dispatch-page-to-Twitter engine (seen at https://twitter.com/Fayettevillains) to Ruby, piece by piece. There are 3 basic components - the scraper, the geolocator, and the Twitter bit. Figure it should be a good entry project. Any general tips/guidelnies for a guy with terminal Perl Stockholm Syndrome?
|
# ? Aug 1, 2013 16:46 |
|
Jonny 290 posted:I'm about a two-year Perl dork that is wanting to goof with Ruby/Rails some. My first goal is going to be porting my police-dispatch-page-to-Twitter engine (seen at https://twitter.com/Fayettevillains) to Ruby, piece by piece. There are 3 basic components - the scraper, the geolocator, and the Twitter bit. Figure it should be a good entry project. Any general tips/guidelnies for a guy with terminal Perl Stockholm Syndrome? I would scrape with nokogiri, geokit is great for geolocation, and there are a bunch of Twitter gems that all work about equally well. I've used this one before.
|
# ? Aug 1, 2013 17:02 |
noob question time: I need to reference a static page in a transactional email, and I need it to reference the instance that is sending the transaction, i.e. my local host, my staging server, or finally production. My remote coworker has done something to set up routing to the static pages in this manner: routes: Ruby code:
Ruby code:
Ruby code:
HTML code:
edit: derp. the answer is to use *_url instead of *_path. Oh well at least the answer was simple. I've been living in coffeescript la la land for too many weeks. A MIRACLE fucked around with this message at 17:03 on Aug 2, 2013 |
|
# ? Aug 2, 2013 16:46 |
|
Sub Par posted:I have a form on which you can post an item, and when you do, I want to handle that post with AJAX and re-render the list of posts. I have my list of posts set up like this: I fixed this when I realized that the @posts instance variable belonged to the User controller and wasn't getting into the Posts controller to be passed to re-render the partial. Added @posts to the Posts controller create method and everything fell into place.
|
# ? Aug 2, 2013 20:09 |
|
I have a form page that's supposed to pass true to a boolean DB column when checked and false when unchecked. The problem is, it doesn't pass anything at all! I've tried all of the following (excuse the HAML):Ruby code:
code:
|
# ? Aug 7, 2013 15:12 |
|
What does the params hash look like when you send the request? Also, check your attr_accessible settings in the User model or strong_parameters settings in your controller (if you're using it). (Also, I'm pretty sure that Rails sets a hidden input field as well, so the parameter should be sent even if the checkbox isn't checked.)
|
# ? Aug 7, 2013 15:34 |
|
Smol posted:check your ... strong_parameters Oh for fucks sake. That was it, I didn't have :newsletter in my params.require(:user).permit(...). Why is it always the really stupid, little things? Oh well, thanks for the help
|
# ? Aug 7, 2013 15:46 |
|
Another question for you guys. I'm playing around with some validation on my signup page - where if they input a username that's too short or a password that doesn't fit the RegEx, they get a little red frowny face in the input box via FontAwesome. I'm having some trouble with jQuery and Rails playing nice together. /app/views/users/new.html.haml (the gist of the form part) : HTML code:
/app/assets/javascript/smiley_checker.js.coffee : JavaScript code:
The problem: when I go to the signup page (/signup) directly, it works fine. When I get to it via a "link_to" on my front page, none of the Javascript works. Is there some Ajax thing going on? Should I be using something other than $(document).ready to initialize my script? Count Thrashula fucked around with this message at 14:33 on Aug 8, 2013 |
# ? Aug 8, 2013 14:24 |
|
QPZIL posted:The problem: when I go to the signup page (/signup) directly, it works fine. When I get to it via a "link_to" on my front page, none of the Javascript works. Is there some Ajax thing going on? Should I be using something other than $(document).ready to initialize my script? It sounds like you're using turbolinks, and you can't use document.ready with that. See: https://github.com/rails/turbolinks/#events Also, not that it's much different, but I've always preferred to do my on-load as code:
code:
kayakyakr fucked around with this message at 15:30 on Aug 8, 2013 |
# ? Aug 8, 2013 15:28 |
|
Say I want to handle pagination in a thread on a forum. My first thought is to use query parameters, but I'm under the impression that isn't the Rails way to do things. Am I right? Because it would be so much easier to throw in a query string than setup routes like threads/:id/:page_number and then have to avoid using built-in path helpers, since stuff like thread_path(@thread) just routes to threads/:id.
|
# ? Aug 9, 2013 05:37 |
|
https://github.com/mislav/will_paginate will make all your paginated dreams come true.
|
# ? Aug 9, 2013 05:42 |
|
Yeah, I'm using that - I'm just taking the :page_number from the URL and handing it to will_paginate. I'm just not sure if I really should be using route parameters for this instead of a query string. Edit: Ohhhhh, wowww, I am an idiot. It seems that will_paginate has a view helper of its own, which actually uses adds a query string to your path helper. So I guess query strings aren't frowned upon in rails and all of my work these past hours has been wasted, but aside from undoing it, I won't have several more hours of making it work. Safe and Secure! fucked around with this message at 05:56 on Aug 9, 2013 |
# ? Aug 9, 2013 05:44 |
|
Safe and Secure! posted:Yeah, I'm using that - I'm just taking the :page_number from the URL and handing it to will_paginate. I'm just not sure if I really should be using route parameters for this instead of a query string. No, query strings aren't frowned upon. You can make "nice" URLs and be happy, but for something like a forum... it's not worth it.
|
# ? Aug 9, 2013 05:57 |
|
Safe and Secure! posted:Edit: Re: query strings vs. routes, it comes down to how Tef-compatible you want your routes to be, and if users need to get there with form fields. yospos.biz/threads/12345/pages/5.html is a separate resource from yospos.biz/threads/12345/pages/6.html , so it's okay that they have different paths; same with yospos.biz/threads/12345/pages/5.json and yospos.biz/threads/12345/pages/6.json (and they better loving have URLs for previous, next, and other referenced resources). At the same time, though, you're using Rails so you don't have to be autistic about routes. As long as your integration tests say that your poo poo is navigable, you'll be fine.
|
# ? Aug 10, 2013 23:43 |
|
This is a very vain and possibly stupid question, but is there any way to customize the colorization of output from the rails CLI? I really like my terminal color scheme but it's like Solarized in that it fucks with bright colors to make them shades of gray. That means the bright green from the rails CLI (like when it creates a file for instance) are basically unreadable.
|
# ? Aug 13, 2013 04:19 |
|
Deus Rex posted:This is a very vain and possibly stupid question, but is there any way to customize the colorization of output from the rails CLI? I really like my terminal color scheme but it's like Solarized in that it fucks with bright colors to make them shades of gray. That means the bright green from the rails CLI (like when it creates a file for instance) are basically unreadable. You could use Pry and then theme it easily with (https://github.com/kyrylo/pry-theme) EDIT: I would advise using Pry over the standard Rails CLI regardless
|
# ? Aug 13, 2013 06:54 |
|
Sanity check please: Edit: Yup, I'm insane, but I just thought of a sane way to do it. Nevermind! That's what I get for coding on a couple hours of asleep after being awake forever. Safe and Secure! fucked around with this message at 08:12 on Aug 14, 2013 |
# ? Aug 14, 2013 07:32 |
|
I need to style the markup of my Rails app's views. Can this just be as simple as looking at the bootstrap documentation and then making sure that all my HTML elements have classes from bootstrap, or is there anything I should keep in mind as go through it? I'm using the bootstrap-sass and sass-rails gems, if that changes anything.
|
# ? Aug 16, 2013 07:38 |
|
Safe and Secure! posted:I need to style the markup of my Rails app's views. Can this just be as simple as looking at the bootstrap documentation and then making sure that all my HTML elements have classes from bootstrap, or is there anything I should keep in mind as go through it? I'm using the bootstrap-sass and sass-rails gems, if that changes anything. It certainly can be that simple -- if you use bootstrap you dont have to ever touch a css file. Your views will look good but they will also look pretty generic as bootstrap is becoming fairly ubiquitous. The bootstrap website has a thing that will let you customize the style and then import it into your project, so you can try that. I didn't find it very useful. If you need something more bespoke, you'll need to get into writing custom css files and using bootstrap mostly as a helper. But if you're starting out, I dont think there's any harm in just bootstrapping everything and then tweaking it from there.
|
# ? Aug 16, 2013 07:53 |
|
chumpchous posted:I dont think there's any harm in just bootstrapping everything and then tweaking it from there. If you're doing this, you might appreciate the bootstrap-sass gem, which lets you write semantic HTML and style it in Sass or SCSS. I've been using Zurb Foundation more recently, just because it's nicer to work with in Rails with Sass.
|
# ? Aug 16, 2013 16:42 |
|
I'm trying to get into test-driven development since that's The Cool Thing right now (and generally not a bad idea). Is Rspec+Capybara all I really need? Or is there a better system that people are using? I've looked at Cucumber, but that seems like an unnecessary extra layer if I'm not going to be working with end-users that need to look at my tests. It seems pointless to write out all the descriptions, then define the descriptions, when I could do the same thing with just adding in comments to the testing code. Cocoa Crispies posted:If you're doing this, you might appreciate the bootstrap-sass gem, which lets you write semantic HTML and style it in Sass or SCSS. Is there a big difference between Sass and SCSS? I've been using the terms interchangeably without even realizing they were different. Also, I generally prefer to have total control over my styling, so I like to use 960 Grid System - all that sweet gridding, none of that extra styling like Foundation or Bootstrap.
|
# ? Aug 16, 2013 17:02 |
The main difference is that SCSS has the braces and semicolons. SCSS is the new hotness mostly because CSS straight up runs as a SCSS conversion. You don't have to change a thing when you swap over from regular CSS. Then you can begin optimizing without trying to make your old stylesheet look like a YAML file.
|
|
# ? Aug 16, 2013 17:55 |
|
rspec and capybara will do the job if you're just getting started. Spork will greatly speed up test startup and run time. If you use any Ajax/js, definitely consider disabling transactional fixtures and installing the database_cleaner gem. It will save you a lot of headache. FactoryGirl is really really awesome, I like it so much I started using it in development.
|
# ? Aug 16, 2013 18:04 |
|
So I'm using a form_for on a model that exists in my application -- that works fine. Create, update, etc. This form is using the multiple select option in Select2, seen here: http://ivaynberg.github.io/select2/ In this form I'm working on, I'm also trying to include an elastic array of digits that get processed uniquely in my controller. I pass these through via an input like so: code:
What I noticed happening is that all those IDs post through, but they always sort in numerical order. So if a user selects multiple values -- say 33, 139, 2 and 5 -- I see them posted in the debug logs as 2, 5, 33, 139. However, I need them to pass through in the order the USER entered them, not the way it seems Rails is auto-sorting them as integers. I have another form that does this similar thing without the order auto-forced, but that uses a form_tag -- not sure if that's the issue or not. That'd make my life a bit harder going that route, but if that's the way to do it I'd be curious to know if anyone's hit something like this before.
|
# ? Aug 16, 2013 21:42 |
|
A MIRACLE posted:The main difference is that SCSS has the braces and semicolons. SCSS is the new hotness mostly because CSS straight up runs as a SCSS conversion. You don't have to change a thing when you swap over from regular CSS. Then you can begin optimizing without trying to make your old stylesheet look like a YAML file. I usually just use sass-convert: http://rdoc.info/gems/sass/file/README.md#sass-convert , it's less work than artisanal hand-converted Sass files. mmachine posted:I have another form that does this similar thing without the order auto-forced, but that uses a form_tag -- not sure if that's the issue or not. That'd make my life a bit harder going that route, but if that's the way to do it I'd be curious to know if anyone's hit something like this before. What order are they coming in over the wire, before Rails has a chance to mangle it?
|
# ? Aug 16, 2013 22:39 |
|
Say you have two models you're exposing as individual resources, say cars and cars_i_own (basically a join table). You often need to know both individually, maybe say to populate a list of all the cars out there, and sometimes to list what cars you actually own. The most pure implementation would be to just have the client do joins itself after getting those resources. You get all the cars, all the cars you own, join the two lists by id. However you could also expose an additional resource that would do that for you on the server side, almost literally a table join between the two models above, and return that blob to the client. What are some arguments in favor or against that approach? On one hand you could save on round-trip-times (as in, "give me all ids of cars I own, fetch all cars with these ids. 2 network calls), but on the other now you're on this slippery slope towards creating join resources for every single model in your system. That's a lot of extra crap. Any thoughts?
|
# ? Aug 16, 2013 22:45 |
|
Keep it simple at first and optimize if it becomes a problem.
|
# ? Aug 16, 2013 23:35 |
|
Smol posted:Keep it simple at first and optimize if it becomes a problem. Define simple? Simple for whom, for the backend or the client?
|
# ? Aug 16, 2013 23:48 |
|
DreadCthulhu posted:Define simple? Simple for whom, for the backend or the client? For yourself. Also the client, but mostly for yourself.
|
# ? Aug 17, 2013 00:00 |
|
|
# ? May 15, 2024 04:17 |
|
QPZIL posted:I'm trying to get into test-driven development since that's The Cool Thing right now (and generally not a bad idea). Is Rspec+Capybara all I really need? Or is there a better system that people are using? I just came from the ChicagoRuby meetup where a couple guys from Hashrocket gave demos/presentations if how to use Rspec and Cucumber. Obviously they have different applications, especially where Cucumber is geared toward the front end. I'm definitely going to be looking into using it on my next project. That said, I'm not sure it's an either/or situation with those. They're different tools that accomplish different things. Capybara was shown as one piece of it as well, but was not the focus of either talk. Edit: I should mention that I was new to all of these tools going into the meetup. I knew about Rspec, but had never actually used it for anything.
|
# ? Aug 18, 2013 00:22 |