|
BonzoESC posted:To keep out browsers, run the android app over https with http basic authentication and a hardcoded password. The https means that people will have to take five minutes to unzip and strings the apk to get your hardcoded password instead of thirty seconds to use wireshark. That seems decent enough, thanks.
|
# ? Jan 4, 2012 06:38 |
|
|
# ? Apr 27, 2024 10:23 |
|
Assuming I'm writing my own tasks, is there anything Rake can do that Thor can't?
|
# ? Jan 4, 2012 06:52 |
Oh man. I am having a hell of a time getting postgres running. It used to work fine... then I didn't use it for a while, now I'm getting the `server not listening error' ( OSX10.7 ) My pg_hba.conf and postgresql.conf check out fine. Running `ps aux | grep postgres' shows that I DO have a server process running: code:
e, oh yeah, here's what ActiveRecord throws: code:
code:
A MIRACLE fucked around with this message at 22:10 on Jan 4, 2012 |
|
# ? Jan 4, 2012 21:59 |
|
A MIRACLE posted:Oh man. I am having a hell of a time getting postgres running. It used to work fine... then I didn't use it for a while, now I'm getting the `server not listening error' ( OSX10.7 ) Where'd you install postgres from? Lion comes with a psql client that doesn't work with homebrew postgres, and it's pretty expedient to sudo rm /usr/bin/psql /usr/bin/createdb /usr/bin/dropdb Also what's your database.yml? Mine works with homebrew postgres and looks like this: code:
|
# ? Jan 4, 2012 22:21 |
BonzoESC posted:Where'd you install postgres from? Lion comes with a psql client that doesn't work with homebrew postgres, and it's pretty expedient to sudo rm /usr/bin/psql /usr/bin/createdb /usr/bin/dropdb Pretty generic: code:
`Running' 9.1, used the installer from PG's website IIRC.
|
|
# ? Jan 4, 2012 22:51 |
|
I installed via brew, and have this in my env $ env | grep pgda PGDATA=/usr/local/var/postgres
|
# ? Jan 4, 2012 23:07 |
|
A MIRACLE posted:Pretty generic: Yeah, it's probably not listening on a port by default and it doesn't silently reconfigure itself to use a local socket like mysql does. Just yank out the username and host stuff.
|
# ? Jan 4, 2012 23:29 |
|
I am the Saul Goodman of freelance Rails development... After setting up an online chat box function. There ya go, all set! The only thing holdin your customer service abilities back now are the shotty English skills of whichever 3rd world citizen employed by whatever company you've decided to outsource to! Don't let em get trolled too hard by some 13 year iPhone wielding snot, bored out of his mind in history class! After setting up an online ticket submission system. Welp, you're good! Good luck with the new online ticket submission system! God knows how anyone's gonna request help from the I.T department when the internets' down, but that's a whole other can of worms I'd rather not get into, cuz I'm off to cash your check, before you can say, "Wait, what?!" After setting up a log in/out user registration database. Ok, all set! Hope it makes you feel more exclusive! Sure registration is free and it doesn't actually grant the user more access to content, but they'll love the redundant spam emails with all the pretty colors, ammirite!? Now let's talk future! What's it your willing to pay me to set up the world's #1 most used analytics platform by Google, on your website!? Hell, if you want, I can bang out some javascript and tie a journey to the registration page so they don't even have to hit "submit" in order to get bombed with spam from your site! Annnnnnnnnnd time! Alright, that app took three hours and twelve minutes. Better make it an even five hours! (I wish I had the balls to say this poo poo to my clients) Seriously though, Rails is awesome and I've pretty much recycled everything I've ever made from the first tutorial I did. I highly recommend this environment to anyone looking to learn how to develop. My only advice is to absorb as much information as you can without trying to bash it into your head. Don't get too bogged down in understanding the details, just write the code, finish your first app and then mess around with it by adding more features. ZanderZ fucked around with this message at 16:42 on Jan 5, 2012 |
# ? Jan 5, 2012 16:37 |
|
... but make sure the first thing you do is learn TDD or BDD for Rails
|
# ? Jan 5, 2012 19:03 |
|
atastypie posted:... but make sure the first thing you do is learn TDD or BDD for Rails A hundred times this. Being fast at writing unmaintainable crap is arguably worse than being slow at it.
|
# ? Jan 5, 2012 19:10 |
|
atastypie posted:... but make sure the first thing you do is learn TDD or BDD for Rails In this vein, do you guys have opinions on PragProg's Cucumber and RSpec books? I'm learning BDD as I go at this job, and would love to have some solid canonical resources to refer to. Thoughts?
|
# ? Jan 5, 2012 20:10 |
Re: Postgres woes; cc: BonzoESC, Pardot Well I'm an idiot and don't know how to read the output of ps, which led me to believe that postgres had an active server process (it didn't). Needless to say today has not been the most productive day as I am still struggling with launching the server. So I do sudo su - postgres to run pg_ctl start, which tells me that I don't have PGDATA set as an env. variable. This is news to me as PG was running flawlessly a few weeks ago. But I digress, export PGDATA=/Library/Postgresql/9.1/data and continue. Then pg_ctl tells me that my data folder has too many permissions. More specifically code:
|
|
# ? Jan 5, 2012 23:22 |
|
A MIRACLE posted:
That only sets the user permissions, it still probably has group or world. Try "chmod 0700 /Library/PostgreSQL/9.1/data"
|
# ? Jan 5, 2012 23:27 |
|
Install postgres from homebrew, follow its instructions, call me in the morning.
|
# ? Jan 6, 2012 00:21 |
|
Just stopping by to say that I setup http://gitlabhq.com/ at work today for internal testing and holy poo poo this kicks asses. Huge props go out to the guys powering this. It's just a fancy Rails app that essentially emulates github for internal networks. Not quite as solid as Github Enterprise but pretty great for free.
|
# ? Jan 6, 2012 01:30 |
BonzoESC posted:Install postgres from homebrew, follow its instructions, call me in the morning. Just got to this. Thanks man I'm good to go now.
|
|
# ? Jan 6, 2012 21:10 |
|
Is there some way to not need code:
|
# ? Jan 7, 2012 05:56 |
|
Doc Hawkins posted:Is there some way to not need Thor's gemspec declares that it wants its lib added to the load path: https://github.com/wycats/thor/blob/master/thor.gemspec#L21
|
# ? Jan 7, 2012 18:42 |
|
Meat Street posted:In this vein, do you guys have opinions on PragProg's Cucumber and RSpec books? I'm learning BDD as I go at this job, and would love to have some solid canonical resources to refer to. Thoughts? Haven't read the Cucumber book, but the RSpec book is one of the best programming books I've read in a long time. TBH it shouldn't even be called the RSpec book, it's basically a complete walkthrough for BDD and covers a load of Cucumber.
|
# ? Jan 7, 2012 19:31 |
|
BonzoESC posted:Thor's gemspec declares that it wants its lib added to the load path: https://github.com/wycats/thor/blob/master/thor.gemspec#L21 Yeah, I've got that in mine, too.
|
# ? Jan 7, 2012 21:28 |
|
redacted
Pardot fucked around with this message at 22:16 on Dec 8, 2013 |
# ? Jan 10, 2012 00:45 |
Yeah, really wanted to go but filled up before I finalized my travel plans. Oh well.
|
|
# ? Jan 10, 2012 06:49 |
|
Can anyone help me better understand methods? I'm trying to write a method for the current user that currently looks like this. def current_user= (user) @current_user ||= user_from_remember_token end It seems pretty redundant, especially considering the fact that I have a controller for users and a controller for sessions and current_user is defined the same way, in both. It's also in both helpers. I'm getting a no method error when I try to use <% if current_user?(display_user.info) %> I assume it's having an issue with the method for current_user or is the error in regards to "display_user.info"? What's a good format for "current user?" I have it set, so it's dependent on cookies, but I'd rather it just assume that "current user" is the user that's currently logged in. Should I be defining it in the users controller or the sessions controller? I'm pretty good at overcomplicating things. ZanderZ fucked around with this message at 17:15 on Jan 10, 2012 |
# ? Jan 10, 2012 16:33 |
|
ZanderZ posted:Can anyone help me better understand methods? I'm trying to write a method for the current user that currently looks like this. First of all, a method called "current_user=" is a setter, and the body of your method is a getter. Also, "current_user", "current_user=" and "current_user?" are all different methods, that's why you're seeing a method not found error. Apart from that I don't know enough about the implementation of your authentication system to be able to say. Are you using a gem for authentication? If you are, you probably don't need to do the implementation for current_user yourself.
|
# ? Jan 10, 2012 17:42 |
|
I think it helps to enumerate the difference between @current_user, current_user, current_user= and current_user? @current_user is an instance variable. That is, a value that is owned by your controller instance. In the Rails world a new controller object is instantiated for each request, so your instance variables are "reset" on every request. current_user is a memoized getter method, and should be like this: code:
current_user= is a setter method, and should be like this: code:
current_user? is method that returns a boolean value, and should be like this: code:
|
# ? Jan 11, 2012 00:04 |
|
epswing posted:I just want to make a quick note here. This is from page one, but I just want to jump in here and say that this post really sums up my exprience at the first couple seconds of looking at that code. The .rhtml makes alot of sense. You don't do the whole html, just the tages you need to represent. But until I saw that example I was still lost. Also what is the deal with always having to inherit form an object? Novo posted:If I wanted a page that listed all people ordered by lastname, I could do this: Like, how do you know which objects to inherit from? Where is the list at? Right now, those first two parts are really losing me, the missing {} and () sucks too. Why do I have to right end if I can just do } I like the way it looks much better. And is the lowercase person the same as the uppercase Person ?
|
# ? Feb 1, 2012 11:05 |
|
Physical posted:Also what is the deal with always having to inherit form an object? Literally everything in Ruby is an Object. '1' is an object of the String class, 1 is an object of the Fixnum class. Physical posted:Like, how do you know which objects to inherit from? Where is the list at? Right now, those first two parts are really losing me, the missing {} and () sucks too. Why do I have to right end if I can just do } I like the way it looks much better. In the examples given, the models and controllers (Person, PersonController 'classes') build on functionality provided by rails, hence they inherit from ('extend') ActiveRecord::Base class which then provides an ORM around using that object (having it go to the database to retrieve itself, for example, and allowing you to 'save' it, etc). The controller code is called in specific ways with specific prefixes/suffixes etc hence extending from ApplicationController (which extends from some other ActionController::Base, i think). Basically, if you didn't extend these classes, you don't get the functionality of rails. Physical posted:And is the lowercase person the same as the uppercase Person ? code:
|
# ? Feb 1, 2012 15:01 |
|
Just to add to that, you don't always have to inherit. I write classes all the time that don't inherit from ActiveRecord. Inheriting from ActiveRecord is when you have a one-to-one class-to-table mapping with your database. If you want to write a class that has other responsibilities, go hog wild. If you want to use { and } rather than do and end you can, but the preferred Ruby style is to use do and end for multi-line blocks and { and } for single line blocks. code:
code:
Finally, not sure who asked it or if it's already been answered, but yes you can craft your own SQL if you need to do something complicated. However, ActiveRecord is powerful and expressive, you don't need to do that very often.
|
# ? Feb 1, 2012 15:24 |
|
I do find that I bump up against the limits of "vanilla" ActiveRecord fairly often, but fortunately, ActiveRecord is built on top of Arel, and there's very little that isn't possible with Arel. It can seem pretty tempting to drop back to SQL, but you are losing some benefits by doing so - for starters, eager loading associations becomes a lot more of a pain, and you won't be able to chain together any pure SQL calls.
|
# ? Feb 1, 2012 16:03 |
|
kalleth posted:Literally everything in Ruby is an Object. '1' is an object of the String class, 1 is an object of the Fixnum class. Uhh maybe thats where my confusion coms from, there is no line that says perosn = Person.find its @people = Person.find.
|
# ? Feb 1, 2012 19:23 |
|
The .find method has the ability to return either one object or a collection of objects. Most of the time .find isn't used anymore and convenience methods are used instead, but here's an example. Again, the code below is no longer the correct way to do this:code:
code:
code:
code:
|
# ? Feb 1, 2012 19:41 |
Pretty much. Read up on .where if you're interested in returning collections.
|
|
# ? Feb 1, 2012 19:43 |
|
It would probably be a good idea to check out something like http://railsforzombies.org/
|
# ? Feb 1, 2012 19:49 |
|
What do the tops of these files look like? How do they get linked together so that person knows where to get its data from?
|
# ? Feb 1, 2012 19:52 |
|
It's split into Model/View/Controller. The framework itself takes care of including all the necessary files so they know how to talk to each other. Let's assume a simple scenario where you have a database table called "people" with columns "first_name" and "last_name". Your goal is to print out a list of these people, ordered by last name, when someone visits http://yoursite.com/people. First the model (app/models/person.rb). This model doesn't need any code because it inherits from ActiveRecord::Base. That means that you automatically get methods like "all" and "find" and "save." However, if you have any heavy duty business logic you want to include it in the model. In our example I'll be defining a method called "full_name" which just concats the first_name and last_name methods. In my example I use "return" and I also refer to "self.", both of which are unnecessary and frowned upon, but they make it easier to understand in this example. code:
code:
code:
|
# ? Feb 1, 2012 20:05 |
|
prom candy posted:It's split into Model/View/Controller. The framework itself takes care of including all the necessary files so they know how to talk to each other. Let's assume a simple scenario where you have a database table called "people" with columns "first_name" and "last_name". Your goal is to print out a list of these people, ordered by last name, when someone visits http://yoursite.com/people.
|
# ? Feb 1, 2012 20:12 |
What's the question, then? Rails is linking them behind the scenes using the inherited ActiveRecord and ActiveController classes. See your routes.rb for examples of invoking ActiveController methods.
|
|
# ? Feb 1, 2012 20:17 |
|
prom candy posted:+ code Thanks for this. I've been working with Rails for the last few months, and while I feel like I've had my nose buried in code books, this was a nice 30,000 foot view.
|
# ? Feb 1, 2012 20:25 |
|
Physical posted:I am at least familiar with MVC methodology and specifically have experienced using it with PHP and Code Ignitor. The major difference between Rails and CI (in my limited experience with an older version of CI) is that Rails practices what's called "Convention over Configuration." Assuming you follow the Rails conventions of putting your files in the right places and naming them the right things (in relation to your database table names, for example) you don't have to explicitly include any files, it's all done for you. In CI if you want to reference a model from another controller you have to specifically say "i'm going to be working with this model" but you don't need to do that in Rails. You can pretty much access anything from anywhere if you know what it's called. Look at the index action in the controller and the index.html template (I forgot to mention that the view would reside in app/views/people/index.html.erb). Rails automatically invokes app/views/people/index.html.erb for the action "index" in the controller "People" because that's the convention. If you wanted to you could render something else. code:
code:
|
# ? Feb 1, 2012 20:54 |
|
|
# ? Apr 27, 2024 10:23 |
|
prom candy posted:The idea and the real appeal of Rails (IMO) is that it automatically does all the tedious stuff for you, provided you stick to the conventions. I'm getting into rails because I had a job interview monday and they are migrating from sharepoint to a new custom solution they want to build. The main lead did some research and said that what you said is why he thought rails will be best. We won't have to take the time to build a database layer inbetween.
|
# ? Feb 2, 2012 00:52 |