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
skidooer
Aug 6, 2001

NotShadowStar posted:

Although I wish that the latest trend in shoving javascript into loving EVERYTHING will go away, like having it be the front-end to your database store that these new and shiny NoSQL things have. What the HELL.
Which database is that? The only NoSQL database I am aware of that even comes close to using Javascript is CouchDB, and even there Javascript is just an option. You can use any language you want to create your views, including Ruby.

Adbot
ADBOT LOVES YOU

Pardot
Jul 25, 2001




skidooer posted:

Which database is that? The only NoSQL database I am aware of that even comes close to using Javascript is CouchDB, and even there Javascript is just an option. You can use any language you want to create your views, including Ruby.

I do a lot of couchdb, and I don't know anyone who doesn't just use the built in javascript. But you're right that you can plug in different view engines.

skidooer
Aug 6, 2001

Pardot posted:

I do a lot of couchdb, and I don't know anyone who doesn't just use the built in javascript.
I wrote a CouchDB adhoc query indexer that is a mixture of Ruby and C, but yeah, I see no reason not to use Javascript for regular views. It is the easiest way to work with JSON.

Secx
Mar 1, 2003


Hippopotamus retardus
I'm trying to parse an HTML file using Hpricot, but I'm having issues extracting "free floating" text which is not enclosed in tags like <p></p>.

code:
require 'hpricot'

text = <<SOME_TEXT
  <a href="http://www.somelink.com/foo/bar.html">Testing:</a><br />
  line 1<br />		
  line 2<br />
  line 3<br />
  line 4<br />
  line 5<br />
  <b>Here's some more text</b>
SOME_TEXT

parsed = Hpricot(text)

parsed = parsed.search('//a[@href="http://www.somelink.com/foo/bar.html"]').first.following_siblings
puts parsed
I would expect the result to be

code:
<br />
line 1<br />		
line 2<br />
line 3<br />
line 4<br />
line 5<br />
<b>Here's some more text</b>
But I am getting

code:
<br />
<br />
<br />
<br />
<br />
<br />
<b>Here's some more text</b>
Is following_siblings not what I should be using here?

Secx fucked around with this message at 20:01 on Dec 8, 2010

Pardot
Jul 25, 2001




The text aren't elements, so I guess they don't count as siblings.

code:
>> pp parsed.search('//a[@href="http://www.somelink.com/foo/bar.html"]').first.following
#<Hpricot::Elements[{emptyelem <br>},
  "\n  line 1",
  {emptyelem <br>},
  "\n  line 2",
  {emptyelem <br>},
  "\n  line 3",
  {emptyelem <br>},
  "\n  line 4",
  {emptyelem <br>},
  "\n  line 5",
  {emptyelem <br>},
  "\n  ",
  {elem <b> "Here's some more text" </b>}]>

also I hope salesforce doesn't gently caress up heroku :ohdear:

smug forum asshole
Jan 15, 2005

Pardot posted:

also I hope salesforce doesn't gently caress up heroku :ohdear:

Wow. Yeah. Here's the official post for everyone else: http://blog.heroku.com/archives/2010/12/8/the_next_level/

Mrs. Wynand
Nov 23, 2002

DLT 4EVA

NotShadowStar posted:

You can make Javascript decent but why bother when there's Lua, IO, Lisp and much better functional languages about

If the first HTML scripting language had been Lisp we would be living in a different world man - I am so serious.

But since that has not happened, Lisp has piss poor support and tooling (compared to, say, python), IO is too young to be taken seriously and Lua is, well Lua is good but it's not actually thaaat much better then JavaScript and JS just has a lot more momentum and mindshare.

Actually other then syntax and a few narrow and specific nit-picks (like boolean casting) there is exceedingly little to hate about JS.

We really could do a lot worse then JS!

IsotopeOrange
Jan 28, 2003

I'm in the middle of a project and the guy I'm working with has been putting all of the database information straight into the production database. Nevermind if this is a good idea or not, is there a way to pull all of this information into the development database? The production database is Amazon RDS, and I'd like to use SQlite for development if possible.

NotShadowStar
Sep 20, 2000
Off the top of my head, adding a Rake task

code:
task :dump => :environment do
  classes = [User, Post, Password] #and so forth
  
  directory "#{Rails.root}/db/dump"
  for klass in classes
    File.open("#{Rails.root}/db/dump/#{klass.to_s}.yml", "w+") do |f|
      klass.send("all") do |rec|
        f << rec.to_yml
      end
    end
  end
end
Didn't test it but that should get you started at least.

Anveo
Mar 23, 2002

NotShadowStar posted:

Off the top of my head, adding a Rake task

...

Also,

code:
desc 'Create YAML test fixtures from data in an existing database.  
Defaults to development database.  Set RAILS_ENV to override.'

task :extract_fixtures => :environment do
  sql  = "SELECT * FROM %s"
  skip_tables = ["schema_info"]
  ActiveRecord::Base.establish_connection
  (ActiveRecord::Base.connection.tables - skip_tables).each do |table_name|
    i = "000"
    File.open("#{Rails.root}/test/fixtures/#{table_name}.yml", 'w') do |file|
      data = ActiveRecord::Base.connection.select_all(sql % table_name)
      file.write data.inject({}) { |hash, record|
        hash["#{table_name}_#{i.succ!}"] = record
        hash
      }.to_yaml
    end
  end
end
or

https://github.com/topfunky/ar_fixtures

https://github.com/adamwiggins/yaml_db

And then a

code:
rake db:fixtures:load

IsotopeOrange
Jan 28, 2003

Anveo posted:

Also,

code:
desc 'Create YAML test fixtures from data in an existing database.  
Defaults to development database.  Set RAILS_ENV to override.'

task :extract_fixtures => :environment do
  sql  = "SELECT * FROM %s"
  skip_tables = ["schema_info"]
  ActiveRecord::Base.establish_connection
  (ActiveRecord::Base.connection.tables - skip_tables).each do |table_name|
    i = "000"
    File.open("#{Rails.root}/test/fixtures/#{table_name}.yml", 'w') do |file|
      data = ActiveRecord::Base.connection.select_all(sql % table_name)
      file.write data.inject({}) { |hash, record|
        hash["#{table_name}_#{i.succ!}"] = record
        hash
      }.to_yaml
    end
  end
end
or

https://github.com/topfunky/ar_fixtures

https://github.com/adamwiggins/yaml_db

And then a

code:
rake db:fixtures:load

Thank you, I'll try this later when I get back to the project.

enki42
Jun 11, 2001
#ATMLIVESMATTER

Put this Nazi-lover on ignore immediately!

Pardot posted:

also I hope salesforce doesn't gently caress up heroku :ohdear:

I was at the announcement keynote, and Benioff swore up and down that they're commited to not touching Heroku culture, but really everyone says that and we'll have to wait and see.

One thing that could be interesting is if they pull off database.com and get it well integrated to heroku. One thing that I don't think Heroku has ever pulled off super well is a good database story - it's fine for small stuff but when you get into bigger stuff (particularly at the enterprise level) it's a bit too inflexible for my tastes.

NotShadowStar
Sep 20, 2000
You can use Amazon SimpleDB, RDS or MongoHQ with Heroku if you like, though. Heroku's philosophy is why do something when others can do it much better?

enki42
Jun 11, 2001
#ATMLIVESMATTER

Put this Nazi-lover on ignore immediately!

NotShadowStar posted:

You can use Amazon SimpleDB, RDS or MongoHQ with Heroku if you like, though. Heroku's philosophy is why do something when others can do it much better?

Yeah, that's true. I guess what I'm saying is that I think database.com is a bit more compelling on it's own. It's probably due to working more in the enterprise space, but having a solution for multitenancy baked right into the product is amazing.

rugbert
Mar 26, 2003
yea, fuck you
Im almost finished making this Rails 3 CMS for someone, but Im trying to set it up so he can update his contact email and have the mailer use that user defined email address to send mail to.

Right now I have this in my mailer

quote:

@email = SiteSetting.first

default :from => "requests@innerquestonline.com", :to => @email.email
default :subject => "Inquiry From InnerQuestOnline.com"

def support_notification(sender)
@sender = sender
mail
end

which works fine on my local machine, but it crashes on heroku. Herplu doesnt seem to like calling the email field. Is there another way I should be doing this?

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
I am having trouble wrapping my mind around how much more simplistic my application is expected to be using Mongoid rather than ActiveRecord. With AR, it felt like having a controller without a matching Model was extremely uncommon. But now it actually is starting to feel as though there is a distinct separation between the layers and the different purposes they are meant to have.

Every second or third model I am ending up re-writing around now, because I'm discovering I no longer need them.

Actually switching from AR to Mongoid is taking a really long time because I am having to re-learn everything I used to know about database best practices.


For a while I was getting confused about why I was meant to rely so heavily on inheritance. But it makes sense, inheritance in Mongoid fixes the following things about AR:

1) Long query times, includes, joins, etc. In general the database does far fewer writes than queries. Mongoid encourages you not to spend a lot of time building complex queries, but instead to just put the data you will need, into the correct places to begin with. Complex writes over complex queries. By using class (model) inheritance, you eliminate all 'polymorphic/habtm/has-many through' and join tables. You don't ned them anymore because any model is actually any other model or vice versa and can be grabbed just by being where you need it.

2) You may have a model that very simply stores an address. You can now take that and embed it anywhere you want without having to worry about load.

3) No more empty fields stored of any kind.

4) Ability to store ANYTHING.

5) i dunno, something.

I am having more problems with having to rewrite code than I was before, but that's because I am updating the application to work much more elegantly while utilizing far fewer models and certainly far fewer 'collections' (tables).

I am stripping out almost everything! It's almost like most of my workload shifted from writing code to interact with the database, to removing all of it.

This is getting ridiculous.


For instance I want to keep track of other users for each user. I used to have a table that stored those relationships but it isn't necessary anymore. I don't even need a second model. For any characteristic that I want to store about the relationship with the other user, the application just now stores two arrays of ids it keeps up to date for me.

8ender
Sep 24, 2003

clown is watching you sleep
I just have to say again that Speedyrails is the best thing ever. Its 1:25am here and they just setup two new applications including repositories and Capistrano deployment recipes for me on my development VPS. I really am starting to think that Maykel at Speedyrails is in fact a Ruby power sentient robot. The man simply does not sleep.

rugbert
Mar 26, 2003
yea, fuck you
Im using S3 with Heroku on a site Im playing around with but the links keep breaking. Im testing the same site, with the same settings on my laptop but S3 works fine. Is there any reason this should be happening?

smug forum asshole
Jan 15, 2005

rugbert posted:

Im using S3 with Heroku on a site Im playing around with but the links keep breaking. Im testing the same site, with the same settings on my laptop but S3 works fine. Is there any reason this should be happening?

Weird. Any more info?

Cock Democracy
Jan 1, 2003

Now that is the finest piece of chilean sea bass I have ever smelled
I'm not familiar with Heroku but is your app in a subdirectory? If so you might want to try adding config.serve_static_assets = true to your config/application.rb

Pardot
Jul 25, 2001




Cock Democracy posted:

I'm not familiar with Heroku but is your app in a subdirectory? If so you might want to try adding config.serve_static_assets = true to your config/application.rb

Heroku makes sure that that is set to true: http://docs.heroku.com/rails3

In exactly what way are the links breaking? Like what status code from amazon? I've been using heroku and s3 for close to a year now with no issues.

Are always broken on heroku, or intermittent?

rugbert
Mar 26, 2003
yea, fuck you
You know what, Im a loving idiot. Ive been using the same bucket, and the same paths in both my heroku app and the one on my local machine. haha sorry!

Yakattak
Dec 17, 2009

I am Grumpypuss
>:3

I really don't care for Ruby on Rails but since Redmine is made with it, I need to cope. I'm trying to get this god drat thing to start, but whenever I run the dispatch.fcgi script, it errors out like so:

code:

/usr/local/lib/ruby/gems/1.9/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:69:in `<class:Dispatcher>': undefined method `cattr_accessor' for ActionController::Dispatcher:Class (NoMethodError)
        from /usr/local/lib/ruby/gems/1.9/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:4:in `<module:ActionController>'
        from /usr/local/lib/ruby/gems/1.9/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:1:in `<top (required)>'
        from <internal:lib/rubygems/custom_require>:33:in `require'
        from <internal:lib/rubygems/custom_require>:33:in `rescue in require'
        from <internal:lib/rubygems/custom_require>:29:in `require'
        from /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/dispatcher.rb:23:in `<top (required)>'
        from <internal:lib/rubygems/custom_require>:29:in `require'
        from <internal:lib/rubygems/custom_require>:29:in `require'
        from public/dispatch.fcgi:22:in `<main>'
ActiveSupport is most definitely installed.

NotShadowStar
Sep 20, 2000
1) Use RVM instead of using the system libraries.
2) Don't use FCGI, use something like Passenger

Or, rule 0

JUST loving USE HEROKU, gently caress

rugbert
Mar 26, 2003
yea, fuck you

NotShadowStar posted:


Or, rule 0

JUST loving USE HEROKU, gently caress

Ok, about rule 0. Im making a couple really simple CMSd sites (for a tattoo artist, and some realtor) and they dont really need anything special.These are going to be low traffic sites and dont need anything cool, I was going to use speedy rails but if heroku is free, is that a good option?

How easy is it to point a domain to a heroku site? Is there a time limit that theyre free for?

smug forum asshole
Jan 15, 2005

rugbert posted:

Ok, about rule 0. Im making a couple really simple CMSd sites (for a tattoo artist, and some realtor) and they dont really need anything special.These are going to be low traffic sites and dont need anything cool, I was going to use speedy rails but if heroku is free, is that a good option?

How easy is it to point a domain to a heroku site? Is there a time limit that theyre free for?

Free forever (or until salesforce forces otherwise), disgustingly easy to point domains to em

CHRISTS FOR SALE
Jan 14, 2005

"fuck you and die"
Has anyone here tried to implement the MetaWeblog API (or rather, any XML-RPC service) in Rails 3? I'm trying to modify my current blog so I can post to it from my iPhone or TextMate. I feel like this is a feature that is more prevalent in blog software, and it's strange to me that there's no "easy way" for one to add XML-RPC services to a Rails app ever since ActionWebService was discontinued (and basically shunned by the Rails community!)...

rugbert
Mar 26, 2003
yea, fuck you

smug forum rear end in a top hat posted:

Free forever (or until salesforce forces otherwise), disgustingly easy to point domains to em

Is it a good idea? I mean, what kind of support would I get for a free site?

NotShadowStar
Sep 20, 2000
Come on now you can do a LITTLE reading on your own

http://legal.heroku.com/support

If you want personal anecdotes some of us have been using heroku for years with zero issues.

smug forum asshole
Jan 15, 2005
Anyone want to review some Ruby code I wrote and make a little bit of money? Not because I think it's going to make me money -- it's a really simple program and nothing that anyone would really want to write. It works, it's just not very good. I want some pointers on style and just opinion about what something in the same vein should look like, from someone who is confident and passionate.

Anyway, PM me or reply so we can talk?!

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
I can't run any of my rails apps anymore. Whenever I try to boot the development server I get this message:

quote:

~/rails3/my_app # rails s
=> Booting WEBrick
=> Rails 3.0.1 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server

And it hangs. If I try to Control-C I get this. The line it is referencing in environment.rb is "MyApp::Application.initialize!" Activity monitor shows 100% cpu from ruby until I quit the process.

NotShadowStar
Sep 20, 2000
Remove your 1.8.7 RVM and reinstall it. This is why you should use gemsets with RVM. That should straighten everything. Otherwise see if Thin works.

Pardot
Jul 25, 2001




NotShadowStar posted:

Remove your 1.8.7 RVM and reinstall it. This is why you should use gemsets with RVM. That should straighten everything. Otherwise see if Thin works.

Also if you're doing 187, check out REE, and put this in your environment, and see if it makes your specs faster. Other spec tips from http://grease-your-suite.heroku.com/#1

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
Thanks guys that optimization slideshow is probably going to be really helpful later on. But I did something horrible and unforgivable to my environment and now I am regretting it.

The steps I took were approximately:
1) [start over remove all rvm'd ruby directories.]
2) rvm install 1.8.7
3) rvm 1.8.7 --default
4) gem install bundler
5) bundle install


e: This is where I am now: linky

It's the same as my problem initially. :(

Nolgthorn fucked around with this message at 14:45 on Dec 22, 2010

NotShadowStar
Sep 20, 2000
Looks like it might be a problem with mongoid. Does creating a fresh gemset and a bare Rails project work?

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
Yeah then it works fine, it's faster than ever. This all started after I performed a restart, maybe I don't have mongoid set up as well as I thought I did.

I need to look into mongodb's settings and whatnot.


e: Yeah I can run the fork of my application as it was before switching to mongoid. So that is most likely the culprit in my system.

Nolgthorn fucked around with this message at 18:09 on Dec 22, 2010

BrokenDynasty
Dec 25, 2003

I'm having a hell of a time trying to put a right side quote (HTML Entity ’) in my en.yml file. Anything I try does not work, and when rendered in the view is either the question mark error thing, or plain text. Does anyone know the proper escaped code for using a right side quote in yml for rendering in a rails view?

unixbeard
Dec 29, 2004

Hi, not sure if this is ok to post here but didn't see it being prohibited. It's also in the SH/SC job thread but I dont read there so I assume some of you probably don't either.

My friend (not me) is looking for a RoR dev for something that may well end up open source. The pay is market rate. It's a community sharing type site, he has a fairly clear idea of what he wants with wireframes/mockups etc. That is about all I know, you can get more details from him by sending a mail to dani.mcgoo@gmail.com with your cv and some samples.

It would be a plus if you are in Sydney, Australia but if not might still be ok, send him a mail and find out.

unixbeard fucked around with this message at 18:19 on Dec 23, 2010

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
I am seeking some kind of link related method that will extract information from external pages via url input. So, if it were a youtube link, perhaps it would return some thumbnail urls and a description. Vimeo would be similar and twitter posts would be, like the content of the twitter post. Things like that?

Something general, that helps assert what may be the content of the link. It would be great if it used apis where available, and otherwise best-guessed at the content of the page.


I've started something myself. In case there truly is not another case of this being attempted already, but I'm hoping a further along version is available.

code:
  def url_parse(url)
    if video = url.match(/http:\/\/(www.)?vimeo\.com\/([A-Za-z0-9._%-]*)((\?|#)\S+)?/)
      return {:website => "vimeo", :id => video[2]}
    elsif video = url.match(/http:\/\/(www.)?youtube\.com\/watch\?v=([A-Za-z0-9._%-]*)(\&\S+)?/)
      return {:website => "youtube", :id => video[2]}
    end
  end

Nolgthorn fucked around with this message at 21:53 on Dec 27, 2010

Adbot
ADBOT LOVES YOU

NotShadowStar
Sep 20, 2000
http://ruby-doc.org/ruby-1.9/classes/URI.html#M003688

For getting the contents of a page I recommend the dual action of Typhoeus and either Hpricot or Nokogiri

NotShadowStar fucked around with this message at 23:14 on Dec 27, 2010

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