Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
revmoo
May 25, 2006

#basta

NotShadowStar posted:

-Rails isn't a language
-You want guides.rubyonrails.org
-Agile Web Development with Rails is the best book there is. If you can't get anything out of it you are handicapped.

http://apidock.com/ should tide you over until you take your medication, but reading the API and method list isn't going to do poo poo for you until you sit down, take a deep breath and understand how Rails works.

Actually you need to step away from Rails for a good while and learn about Ruby. What you're doing is trying to learn Django, Struts or ASP.NET MVC without knowing any Python, Java or C# at all.

Sorry, I just spent a solid 8 hours poring over the rails site and Google and blogs searching for shreds of information. I feel like I'm reverse-engineering this framework just to try and learn it because there's really no documentation. The official Rails site is very 'lead by example' instead of being an actual reference like I'm used to with php.net.

I'm definitely handicapped. I read Agile web development basically cover to cover last week and didn't really get anything out of it. I'm just used to PHP, which while it is a very messy, ugly language, works very well for web app development and is actually documented.

I'll try the ruby approach. I thought Rails was something you could just learn, but that is clearly not the case.

Can someone reassure me as to the business case for Rails? It seems like a very defunct language for something that is still being actively developed. It seems like every company that has tried to scale with it has eventually failed. The company I'm contracting with right now is gaga over it and I am getting a bad vibe about the whole language. Senior level devs are taking weeks and months to get poo poo done in Ruby that takes me days to do in PHP.

Adbot
ADBOT LOVES YOU

NotShadowStar
Sep 20, 2000

revmoo posted:

Can someone reassure me as to the business case for Rails? It seems like a very defunct language for something that is still being actively developed. It seems like every company that has tried to scale with it has eventually failed. The company I'm contracting with right now is gaga over it and I am getting a bad vibe about the whole language. Senior level devs are taking weeks and months to get poo poo done in Ruby that takes me days to do in PHP.

I think you're reading angry blogs from 2006 because everything you said is completely not true. Twitter runs on Rails. Groupon runs on Rails. Amazon has lots of Rails internally. People are actively identifying performance issues in Rails and attacking them head on. Rails 3 is way faster than anything ever. The Ruby language is not deliberately gimped by a single entity like Zend so you have to go and buy the 'enterprise' from Zend to un-gently caress the interpreter.

"Rails doesn't scale" is completely 2006. In fact, it's come to pass that Rails/Django scales better than everything else out there, it's the databases that don't hold up well. yellowpages.com now runs on Rails, they did a talk on 2009 on how Rails scaled. like. a. boss. while Oracle kept falling on its face.

If you read the Agile book and did the tutorial and you're still completely lost, I have no idea. Also your 'lack of documentation' is like... what the gently caress? Did you see guides.rubyonrails.org? I don't know what you're used to, but everything else I've touched I wish had anywhere near the documentation that Ruby libraries do. The only thing I've seen come close is Wordpress and high quality JS libraries like jQuery, Mootools and such.

p.s. you're still doing Rails = language. Ignore Rails entirely right now. Start here: http://pragprog.com/book/ruby3/programming-ruby-1-9

NotShadowStar fucked around with this message at 23:45 on Jul 28, 2011

revmoo
May 25, 2006

#basta
Ok but what about rails-specific functions? Where is the reference for those?

smug forum asshole
Jan 15, 2005

revmoo posted:

Ok but what about rails-specific functions? Where is the reference for those?

http://api.rubyonrails.org/ :)

edit: I'm surprised you didn't come across this when googling rails-specific classes or methods :geno:

smug forum asshole fucked around with this message at 00:06 on Jul 29, 2011

NotShadowStar
Sep 20, 2000

revmoo posted:

Ok but what about rails-specific functions? Where is the reference for those?

STOP
WITH
RAILS

Seriously. There is no such thing as a 'function' in the RUBY LANGUAGE.

LEARN THE LANGUAGE FIRST.

revmoo
May 25, 2006

#basta
Fuckin method, you know what I mean.

Bob Morales
Aug 18, 2006


Just wear the fucking mask, Bob

I don't care how many people I probably infected with COVID-19 while refusing to wear a mask, my comfort is far more important than the health and safety of everyone around me!

NotShadowStar posted:

I think you're reading angry blogs from 2006 because everything you said is completely not true. Twitter runs on Rails. Groupon runs on Rails. Amazon has lots of Rails internally. People are actively identifying performance issues in Rails and attacking them head on. Rails 3 is way faster than anything ever. The Ruby language is not deliberately gimped by a single entity like Zend so you have to go and buy the 'enterprise' from Zend to un-gently caress the interpreter.

It seems like I've read a bunch of blog articles about replacing this part and that part of Twitter with Java (or something else) in place of Rails.

On a side note, our first 'Rails 3' app does something goofy and freezes our server up a couple times a day. The server also runs Rails 2 apps so we are going to throw up another virtual server or something just for that app, and future apps. 3.09, I'm not sure exactly what's going on with it but another of our developers said it's a problem plenty of others are having.

Bob Morales
Aug 18, 2006


Just wear the fucking mask, Bob

I don't care how many people I probably infected with COVID-19 while refusing to wear a mask, my comfort is far more important than the health and safety of everyone around me!

revmoo posted:

I'm definitely handicapped. I read Agile web development basically cover to cover last week and didn't really get anything out of it. I'm just used to PHP, which while it is a very messy, ugly language, works very well for web app development and is actually documented.

Did you read it, or are you actually working through it?

revmoo
May 25, 2006

#basta

Bob Morales posted:

It seems like I've read a bunch of blog articles about replacing this part and that part of Twitter with Java (or something else) in place of Rails.

Yeah Twitter has to be the worst example. They were offline for weeks because of their choice to run Rails, and they finally replaced most things w/ Scala eventually. They're still running some Rails, I think on the front-end, but it's a pretty bad example of successful implementations.

Pucklynn
Sep 8, 2010

chop chop chop
Ravelry runs completely on Ruby on Rails, and has from the very beginning! It's where I first heard about it, and what got me into Ruby in the first place.

Sharrow
Aug 20, 2007

So... mediocre.
I hate the Twitter comparison. A lot of it is true, but I think there's a slight difference between "scaling" and "being one of the most popular websites in the world handling 7000 tweets per second". No poo poo a generic web framework doesn't handle that out of the box.

Bob Morales
Aug 18, 2006


Just wear the fucking mask, Bob

I don't care how many people I probably infected with COVID-19 while refusing to wear a mask, my comfort is far more important than the health and safety of everyone around me!

Turns out we have Passenger 2.2.x which doesn't have smart spawning, and we need to upgrade our production server to Passenger 3.0, which our staging server has been running.

Evil Trout
Nov 16, 2004

The evilest trout of them all

Sharrow posted:

I hate the Twitter comparison. A lot of it is true, but I think there's a slight difference between "scaling" and "being one of the most popular websites in the world handling 7000 tweets per second". No poo poo a generic web framework doesn't handle that out of the box.

Also the Twitter engineers were amateurs.

Their databases had no indexes when they launched! None!

They also wrote their own message queue in Ruby, when there was a dozen great ones to choose from.

They claimed Rails couldn't support Master/Slave replication of Mysql, and they were shown how to do it in about a dozen lines of code that same day.

And then at every opportunity they've blamed Rails for their scaling issues. It really pisses me off.

Molten Llama
Sep 20, 2006

Evil Trout posted:

And then at every opportunity they've blamed Rails for their scaling issues. It really pisses me off.

VC investors tend to frown upon your admitting you're inept.

Demonstrating it through your terrible products is fine, actually plainly stating it in words is not. Why kill the foosball-and-Cisco-phone-laying goose when you can throw your framework under the bus?

skidooer
Aug 6, 2001

revmoo posted:

They're still running some Rails, I think on the front-end, but it's a pretty bad example of successful implementations.
Actually, I'd say it's a shining example. Despite the constant Rails hate that came from them and them having rewrote virtually everything else in the stack, they still have not replaced the Rails application itself. If it was really that bad, it would have been the first to go.

Plastic Jesus
Aug 26, 2006

I'm cranky most of the time.

Pardot posted:

A couple of things to try, more or less in order:

* Make sure the Cache-Control header is something like Public, max-age: bignumber. I'd have to look up the exact syntax.
* make sure last-modified header is set.
Those two might be all you need. They are set for actual static files, but since you're sending the data yourself, they probably aren't set any more. Once you have those you'll get browser caching again
* try http://rtomayko.github.com/rack-cache/ and also this technique https://gist.github.com/9395
However if you're not careful with this you'll lose the user checking.

Alternatively, you could store all the photos in S3, and just generate short-lived urls on demand if they have permissions. That's what I would probably do, since anything I write that has uploads just puts them in s3 to begin with. Since local disk is ephemeral ;)

Thanks for this. I'm hesitant to provide a max-age since the images do change and not on a predictable basis. I now set Etag and Last-Modified in PhotoController#show but unless the browser sends a HEAD request before each GET are those going to matter?

mmm11105
Apr 27, 2010
Reading the poignant guide to Ruby to get my ruby down before going in. However, my brain can't seem to get all the metaprogramming stuff. Is that really necessary for Rails???

NotShadowStar
Sep 20, 2000
The internals of Rails used to be a huge metaprogramming mess, but Rails 3 is much, much nicer. You hardly ever do metaprogramming in Ruby, only when you really need to abstract stuff out to the outer planets. The one thing you should really take away from all the metaprogramming talk is that classes are always open and can be modified and extended at any time in a variety of ways: directly by re-doing 'class Stuff', or indirectly through 'Stuff.class_eval', including Modules, and on and on and on. That's used quite a bit, but the stratosphere level define_method, send_message, and method_missing stuff you should never have to touch.

Pardot
Jul 25, 2001




Plastic Jesus posted:

Thanks for this. I'm hesitant to provide a max-age since the images do change and not on a predictable basis. I now set Etag and Last-Modified in PhotoController#show but unless the browser sends a HEAD request before each GET are those going to matter?

I think you can get rack-cache to still store that stuff without the max-age, but I'm not sure. If rack-cache has it, it'll check against the etag and work correctly as a cache.

quote:

metaprogramming

I agree with everything nss said, and think it's time again for [img-metaprogramming]

Only registered members can see post attachments!

A MIRACLE
Sep 17, 2007

All right. It's Saturday night; I have no date, a two-liter bottle of Shasta and my all-Rush mix-tape... Let's rock.

Doing a project in rails for work. I have all these .ind files in a tmp directory, do those need to be in version control? My office uses SVN :( Should I be using git instead?

Doc Hawkins
Jun 15, 2010

Dashing? But I'm not even moving!


A MIRACLE posted:

Doing a project in rails for work. I have all these .ind files in a tmp directory, do those need to be in version control?

.ind files as in, InDesign? I'm not familiar with the program, but if it outputs html and css, then those are the files that should definitely be checked in. I'd ask your work if they want to save the project files that way as well.

quote:

My office uses SVN :( Should I be using git instead?

I'd say yes, but then, I'm an ideologue. Read up on git-svn and choose for yourself. :)

8ender
Sep 24, 2003

clown is watching you sleep
We just switched to git here and it loving rules rules rules. I have no one to blame but myself for clinging to familiarity of SVN for so long.

Anveo
Mar 23, 2002
All of the Pragmatic Programmer print and ebooks are 40% off this week! http://media.pragprog.com/newsletters/2011-08-08.html

kitten smoothie
Dec 29, 2001

8ender posted:

We just switched to git here and it loving rules rules rules. I have no one to blame but myself for clinging to familiarity of SVN for so long.

Yeah, I absolutely love being able to branch willy-nilly and commit while offline. Especially the committing while offline; I used to use SVK with SVN for that, eventually it would always get dog slow or corrupt my local repo with all the SVK history and that turned into a nightmare fast.

Stup
Mar 19, 2009

Pardot posted:

Your conditionals there are just checking that the number 2 is greater than the number 1 or not. I have it on good authority that 2 is always greater than 1, and 1 is never greater than 2.

Having this class need to know what "Forward" means is awkward, put this in whatever class members are.
code:
def forward?
  gen_pos == "Forward"
end
then you can do this.
code:
def cant_have_more_than_one_forward
  # if members.select(&:forward?).size > 1 # id do it like this, but 
  if members.select {|member| member.forward? }.size > 1 # this might make more sense to you, but it's the same thing.
    errors.add_to_base "Can't have more than 1 forward"
  end
end

So I finally got around to sticking this code in as I've been very busy the past few weeks with other stuff, and it worked handily! Thanks very much for your help!

One last question related to this, the error it generates here looks like this:
code:
["Can't have more than 1 forward"]
Is there anyway to get rid of the brackets and the quotations"

Thanks again!

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense

revmoo posted:

Fuckin method, you know what I mean.

I feel your pain a little bit.

Rails 3 might be faster than everything else, but from a cosmetic standpoint it also started using a lot of different files with a lot of different filetypes. I've begun falling out of the loop while more and more different files doing different things are scattered all over the place. Some of them I am required to edit several of to do a simple configuration change instead of just one like before.

New technologies are being applied across the board in order to gain those speed enhancements, but none of them feel very vanilla. A lot have started feeling a little bit more like plugins, being bolted to the very internals that are driving Rails applications.

It feels (to me) like the modulability which is generally a good thing of the base technologies now being used in Rails indicates that people creating the underlying Rails framework, don't really care about Rails specifically. Perhaps that people creating the underlying technologies, envision a near future where Rails gets replaced by something else, like it's their fantasy. Perhaps they don't like the internals of Rails very much and think it's just a good medium with which to show off their technological enhancements because Rails is currently such a popular framework.

It feels (to me) like Rails is getting new stuff attached to it left and right to make it work better, but that ultimately we could start over and develop a framework designed to make use of the same technologies from scratch, better.

You do need to learn ruby though, all of that aside... it's a really powerful language. Leave all this framework stuff until after.

Nolgthorn fucked around with this message at 04:05 on Aug 9, 2011

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

Nolgthorn posted:

It feels (to me) like Rails is getting new stuff attached to it left and right to make it work better, but that ultimately we could start over and develop a framework designed to make use of the same technologies from scratch, better.

The additions DHH addressed at Railsconf (Haml, Sass, Coffeescript) are all in the Gemfile for a new project; you're encouraged to be aware of and modify that file as you need to. You could build a "framework from scratch," and I think you'll find that Rails 3 is actually an excellent base to use for this. It's modular enough for you to swap out ActionView, ActionController, ActiveRecord, etc.

NotShadowStar
Sep 20, 2000

Nolgthorn posted:

It feels (to me) like Rails is getting new stuff attached to it left and right to make it work better, but that ultimately we could start over and develop a framework designed to make use of the same technologies from scratch, better.

Look at Padrino. It's a completely modular, agnostic framework that utilizes Sinatra for the busywork of http. I wrote a recent project in it using that as the base, with Haml, Sass and Mongoid and it was pretty nice. Don't need MVC, but want the M and V? No problem, you can just map routes like Sinatra but the structure is Rails-like. I got into it because the project was going to be just one or two URLs but very heavy on the view and model parts, and I missed the generators of Rails that Sinatra doesn't have. It's a very nice middle ground.

A MIRACLE
Sep 17, 2007

All right. It's Saturday night; I have no date, a two-liter bottle of Shasta and my all-Rush mix-tape... Let's rock.

I think SASS is pretty neat. But do I have to leave the Sass CLI listener open and watching my .scss files for diffs, or can the interpreter just use them un-converted by virtue of having the .scss extension? Windows dev here.

Plastic Jesus
Aug 26, 2006

I'm cranky most of the time.

A MIRACLE posted:

I think SASS is pretty neat. But do I have to leave the Sass CLI listener open and watching my .scss files for diffs, or can the interpreter just use them un-converted by virtue of having the .scss extension? Windows dev here.

They have to be converted to regular CSS on-disk. You don't strictly have to leave the converter running all the time, that's just a nice-to-have when you're testing/tweaking your scss mods.

Anveo
Mar 23, 2002

A MIRACLE posted:

I think SASS is pretty neat. But do I have to leave the Sass CLI listener open and watching my .scss files for diffs, or can the interpreter just use them un-converted by virtue of having the .scss extension? Windows dev here.

If you are using OSX livereload it has nice little GUI widget to monitor your watched folders. And if you are not using livereload you probably should be!

hmm yes
Dec 2, 2000
College Slice
How do I set LiveReload to compile only my application.scss, which is nothing but SASS @import _partial.scss? And recompile it when a partial is changed.

Edit: ah, you can't, yet.

hmm yes fucked around with this message at 18:54 on Aug 9, 2011

Pardot
Jul 25, 2001




I don't understand the appeal of scss. Sass is great though.

A MIRACLE
Sep 17, 2007

All right. It's Saturday night; I have no date, a two-liter bottle of Shasta and my all-Rush mix-tape... Let's rock.

Pardot posted:

I don't understand the appeal of scss. Sass is great though.

I like it a little better. I'm weird and like braces and semicolons though.
code:
@mixin shadow($x, $y, $b, $color: $dark-gray) {
  -moz-box-shadow:$x $y $b $color;
  -webkit-box-shadow:$x $y $b $color;
  -o-box-shadow:$x $y $b $color;
  box-shadow:$x $y $b $color;
}

div {
  @include shadow(0px, 5px, 20px);
}

MuffinShark
Sep 9, 2010
I'm just learning rails and ruby and I was wondering if someone can give me some tips.

I'm working on my app and I've hit a validation snag that I don't know how to get around. Basically I have a date field and I have a new action that allows the input of a date but I'm not using the form helpers to make the date fields. Instead i'm using text fields.

code:
<%= text_field_tag 'birthday_month', nil, :placeholder => 'MM', :maxlength => 2 %>
<%= text_field_tag 'birthday_day', nil, :placeholder => 'DD', :maxlength => 2 %>
<%= text_field_tag 'birthday_year', nil, :placeholder => 'YY', :maxlength => 2 %>
Then I combine them and turn them into a date using Date.strptime. This works great except when an invalid date (entering 99 for the day or 17 for the month) is entered and then it errors out. I have no idea how to even start on the validations for this. I'm not sure if I can use the model validations since I am erroring out on the Date.strptime. So I guess I need to validate in the controller instead?

I'm teaching myself rails having very little programming experience so I may be going about this all wrong.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense

NotShadowStar posted:

Look at Padrino. It's a completely modular, agnostic framework that utilizes Sinatra for the busywork of http. I wrote a recent project in it using that as the base, with Haml, Sass and Mongoid and it was pretty nice. Don't need MVC, but want the M and V? No problem, you can just map routes like Sinatra but the structure is Rails-like. I got into it because the project was going to be just one or two URLs but very heavy on the view and model parts, and I missed the generators of Rails that Sinatra doesn't have. It's a very nice middle ground.

.... :D

This has respond_to, a mailer, form helpers... it's like sinatra only I want to use it, it's like rails except trimmed down!

I love it i think


Haml, Sass and Mongoid is pretty much my thing these days too. thanks

Pardot
Jul 25, 2001




MuffinShark posted:

I'm just learning rails and ruby and I was wondering if someone can give me some tips.

It's been a while, but I think datetime_select does all of this for you.

Bob Morales
Aug 18, 2006


Just wear the fucking mask, Bob

I don't care how many people I probably infected with COVID-19 while refusing to wear a mask, my comfort is far more important than the health and safety of everyone around me!

What's going on here?

code:
@promotion.evaluations[1..99].each do |subsequent_evaluation|
 ...
 ...
 ...
end
Why wouldn't you just do @promotion.evaluations.each? Coming from a C background, that would be an array of evaluations (which could be arrays themselves)

Plastic Jesus
Aug 26, 2006

I'm cranky most of the time.

Bob Morales posted:

What's going on here?

code:
@promotion.evaluations[1..99].each do |subsequent_evaluation|
 ...
 ...
 ...
end
Why wouldn't you just do @promotion.evaluations.each? Coming from a C background, that would be an array of evaluations (which could be arrays themselves)

It means 'loop through indexes 1 to 99 in the array @promotion.evaluations'. for the c folk this would be
code:
for(int i = 1; i <= 99; ++i){
   subsequent_valuation = promotion->evaluations[i];
   ...
}

Adbot
ADBOT LOVES YOU

Bob Morales
Aug 18, 2006


Just wear the fucking mask, Bob

I don't care how many people I probably infected with COVID-19 while refusing to wear a mask, my comfort is far more important than the health and safety of everyone around me!

Plastic Jesus posted:

It means 'loop through indexes 1 to 99 in the array @promotion.evaluations'. for the c folk this would be
code:
for(int i = 1; i <= 99; ++i){
   subsequent_valuation = promotion->evaluations[i];
   ...
}

Gotcha. In this particular case they'd want ALL the evaluations for the promotion so I'm not sure why they would put 0-99. Ugh.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply