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
kayakyakr
Feb 16, 2004

Kayak is true

manero posted:

Look for a local Ruby or Rails user group -- I organize the MN Ruby user group, and it's an awesome way to learn and network with people.

This is a good idea. I know Austin has one that is filled with companies looking for Rails people. They do monthly meetings with two presentations where the first is geared toward rails beginners.

Adbot
ADBOT LOVES YOU

kayakyakr
Feb 16, 2004

Kayak is true

mmachine posted:

So question is, how do I get the Book CanCan permissions defined already in my ability.rb to descend to child record(s) of the Book model? CanCan documentation reads like this should happen based on my native model definitions for the app, but that doesn't seem to be the case. Do I also need to define relationships within CanCan's Ability model or what? If so, is there a decent example someone can provide?

How are you assigning to the pages class? If you aren't assigning via the book class, then it probably won't pick up the CanCan ability. I'm not sure if just doing book.pages.create will be enough to assign through books.

kayakyakr
Feb 16, 2004

Kayak is true

mmachine posted:

I'm assigning page classes for my application via the core model definitions for my app. That relationship has been in place for a while now, and works no problem. The CanCan implementation is pretty recent, which is why I'm kind of confused as to where I'm not re-affirming these relationships for CanCan.

When you say assign via the book class, do you mean via a CanCan-specific method?

Sorry, I was wrong on how CanCan is implemented. New set of questions about your implementation:
Are you using shallow routes (/pages/:id) or deep routes (/books/:book_id/pages/:id)?
Outside of the load_and_authorize_resource block, how are you using CanCan?

One note in my searches that I ran across: to use load_and_authorize, CanCan needs some sort of searching done on its ability. Your ability file could theoretically be designed as
code:
can :manage, Book, :author => {:id => author.id}
That should help the second part work, maybe?

kayakyakr
Feb 16, 2004

Kayak is true
Time Zones in any language are a huge pain in the rear end.

If you have a particular zone you want the time in, you can use

code:
  DateTime.now.in_time_zone("Eastern Time (US & Canada)")
This will take care of DST and any zone stuff you need. If that zone's gotta be dynamic, well... good luck?

kayakyakr
Feb 16, 2004

Kayak is true

soullessshoe posted:

Regarding the timezones: the offset is coming from client side, being saved to a cookie, then read server-side.

problem is that the current offset is passed from client side whereas ActiveSupport::TImeZone#[] does the lookup by standard timezone offset.

Hence the reason I am doing the crazy
Ruby code:
 zone.now.utc_offset
comparison

Ok, so my understanding might be too simple, but how about outputting date to string, parsing it server side, and taking what you get in ruby? With some manipulation it would give you the right zone without worrying about DST.

JS:
code:
(new Date()).toString();
ruby
code:
date = DateTime.parse(in_date)
date.zone == '-05:00'

kayakyakr
Feb 16, 2004

Kayak is true
New is a view-only route. The create is triggered by POSTing the index route, ie athlete_training_plans_path.

The route helper you should be using shows on the left side of the route output and is the last one listed above. Create (POST) is athlete_training_plans, Update (PUT) and destroy (DELETE) are both on athlete_training_plan. New and Edit just get the forms, you don't post back to them.

kayakyakr
Feb 16, 2004

Kayak is true

KoRMaK posted:

I have a namespace in my routes. Pages in that namespace are not having the application.js compiled for them. What are things I should be considering when when it comes to namespaced routes and the asset pipeline?

Are they on a different layout? As long as they're in the same layout, they should be including application. Otherwise, make sure whatever layout they're in is including application.js. The asset pipeline doesn't really care much about routes.

Newbsylberry posted:


code:
Parameters: {"utf8"=>"✓", "authenticity_token"=>"E0qb8OMJytqNdgZAZbZNSN2cIoJKkkar7JZ33a3B80Q=", 
"training_plan"=>{"planName"=>"Hello", "planStartDate(1i)"=>"2011", "planStartDate(2i)"=>"7", "planStartDate(3i)"=>"12", 
"planEndDate(1i)"=>"2013", "planEndDate(2i)"=>"7", "planEndDate(3i)"=>"12"}, "commit"=>"Create Training plan", "athlete_id"=>"1"}


code:
        <td><%= link_to 'Edit', edit_athlete_training_plan_path(training_plan) %></td>
        <td><%= link_to 'Destroy', athlete_training_plan_path, method: :delete, data: { confirm: 'Are you sure?' } %></td>
I updated my controller too, so here's what I updated:

code:
    @training_plans = @athlete.training_plans.new(params[training_plan_params])

Selected just the code that's causing you issues. edit_athlete_training_plan_path is expecting an athlete id and a training plan id. Apparently it's not smart enough to pull those off of the object, but you can.

code:
edit_athlete_training_plan_path(training_plan.athlete_id, training_plan.id)
athlete_training_plan_path(training_plan.athlete_id, training_plan.id)
And your problem with saving is that params[training_plan_params] is not what contains the training plan properties. Take a look at what your server is telling you the params object looks like (also left in the quoted text above). That should also be a symbol or string, otherwise you're basically looking up params[undefined] or params[nil] which would also be nothing.

kayakyakr
Feb 16, 2004

Kayak is true

Lexicon posted:

Wondering if you guys have any thoughts on migrating a table from being in MySQL to some sort of non-relational form? Our app has a table with several million rows, and is growing rapidly. One of the columns is a hash that we manipulate/store various elements in that don't otherwise belong as columns, but is serialized as JSON.

I know that MongoDB stores JSON objects so this seems like a natural fit? I was thinking we'd merge the other columns with the hash column and store that thing in MongoDB. Does rails support it reasonably well as a persistence layer?

I enjoy Mongoid as an ORM. Does a good job and is pretty easy to move over to for those used to relational db's.

I don't know how migrating to it would go. Are you sure you shouldn't just refactor your current relational database? A meta column is usually not a good idea and when your table is going to grow to to millions of rows, that means you've got other things going on.

kayakyakr
Feb 16, 2004

Kayak is true

Obsurveyor posted:

Development machine with identical staging and production machines. Dev and staging servers are virtual machines. Development happens on dev machine. Seperate development and master trees. Development branches get merged to development tree when tests pass and then pushed to staging server with capistrano for testing/preview/etc. Once the code is ready, it gets merged into the master tree and put into production. Staging server also lets the marketing person create content without making it available to the public.

It's a little complicated for a solo developer and two marketing people but it has its benefits. For small, well known changes, I just skip staging and go straight to production but code still passes through the correct trees.

This is probably the safest, most "correct" process. For most of the stuff I do, I've gotten into the habit of testing locally and pushing straight to the production server. *shrug* It is what it is.

theodop posted:

Do people typically use an IDE with git integration as their main platform, and then when it comes time to affect changes copy the files to the dev environment on the server, run the migrations, and then test, and if it's all good repeat the process for live?

I think most people use command line git and then either capistrano or an environment like heroku where a remote repository lives on the production server and promoting to production is just a matter of pushing to it.

If you're working with rails, get comfortable with terminals and your productivity will go way up.

kayakyakr
Feb 16, 2004

Kayak is true

KoRMaK posted:

Instead of writing that as SQL I would have written it as a ruby loop.

e: inside of the migration. Like this

Ruby code:
class AddClassToItems < ActiveRecord::Migration
  def change
    add_column :items, :class, :integer
    
    #also create settings for these fields
    g = Guide.create(:section => "items", :field_name => "class")      
    s = Setting.create( :account_id => -1, :field_guide => g, :order => 10)

  end
end

Unless it's a very small amount of data that you are migrating, don't do this. Write SQL to do mass inserts and decrease your downtime.

Also, I would suggest writing local classes to the migration to handle things that you may need. This way, if you ever change the classes in the codebase in the future, your migration will still work. MyClass.reset_column_information will reload the tables.

Having to restart the server shouldn't be a huge issue because you're going to be running this migration in a Capistrano update task, right? Right?!

kayakyakr
Feb 16, 2004

Kayak is true

Newbsylberry posted:

I can't seem to figure this out, it seems like it should be working correctly. training_plan_params is a method:

code:
    def training_plan_params
      params.require(:training_plan).permit(:planName, :planStartDate, :planEndDate)
    end
At first I thought the problem was that my _form is referring to @training_plans, and the method is referring to :training_plan, but even after switching all of my @training_plans to just @training_plan, it doesn't seem to work.

Sorry for all the basic questions, and thanks in advance for the help!

Edit - I am using Rails4 and Ruby2.0, Should I be learning in 3.2? The tutorials I am working with mostly use 3.1, but I wanted to mess around with the most recent versions.

As you pointed out, training_plan_params is a method. You want:
code:
@training_plans = @athlete.training_plans.new(training_plan_params)





e: I was looking at the state of running background tasks and such. Right now it looks like the top two options for running anything separate the request thread are delayed job and resque, correct? Would I be daft if I made a gem that used thread pooling and ran background items (example: sending mails) in threads attached to the server instance?

kayakyakr fucked around with this message at 23:45 on Jul 18, 2013

kayakyakr
Feb 16, 2004

Kayak is true

Safe and Secure! posted:

Is there anything I can do, or any reason for me, to try prevent users from entering dangerous stuff as, say, usernames and email addresses in my Rails 4 app? I know there's a sanitize helper for the views, and I guess I could just run input through that before creating a model, but I'm interested in validations for this.

I guess the best I can do is write a custom validator with a regex that detects particular characters?

What are you trying to protect from? Injection attacks? Setting values that they aren't supposed to be accessing?

Any model changes (ie Model.create, Model.update) sanitize their values on setting them. The ARQI where method also sanitizes the values coming in. The "rails way" is fairly strong against injection attacks, just as long as you go through the sanitized methods.

If you're worried about mass assignment problems, this is the new way to do it in rails 4:
http://api.rubyonrails.org/classes/ActionController/StrongParameters.html

You should validate, but I prefer to keep validation to business logic. Unless there's a particular attack or vulnerability that you're worried about, I'd suggest the same. In your case, this would be validating that it is a valid email and validating the uniqueness of the username and email.

kayakyakr
Feb 16, 2004

Kayak is true

Safe and Secure! posted:

I was thinking primarily of preventing someone from sticking script tags in a username field, but I'd like to protect against whatever is feasible for me to be protecting from before sticking stuff into my database.

Right now I have my User model validate uniqueness of names and emails. I also make sure the email has a '@', and I reject any name that matches /\W/ (non-alpha-numeric plus underscore), and I reject any email that matches /[!#\$%\^&\*\(\)-\+\=\_\?\|\[\]\{\}:"',\\\/<>]/.

I realized that the ARQI method where sanitized queries, but I did not realize that AR's model-changing methods also did that. I guess there isn't much for me to worry about from a security standpoint, then, so I can focus my attention on validating rather than sanitizing input? So I can just get rid of the nasty email regex (which is probably wrong)?

pretty much. Use any one of a million standard email regex queries that are on the net, but don't worry too much about having to sanitize every value that comes in, as long as you're using rails' standard methods to put that data in place.

Though if you want to insult people trying simple injection attacks, that would be a good use of pre-checking.

kayakyakr
Feb 16, 2004

Kayak is true

Smol posted:

That's great if you can send an test email to the user (e.g. a registration confirmation email). If not, I'll be more careful about it. Won't use any regex to do the validation though.

how are you being more careful, per se?

kayakyakr
Feb 16, 2004

Kayak is true

manero posted:

Guys, email-based activation is really easy to do.

I've done it so many drat times now with sorcery it takes 15 minutes of work and is totally worth it.

Edit: And using the Mandrill SMTP servers you even get 12k messages per month free.

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.

kayakyakr
Feb 16, 2004

Kayak is true

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.

kayakyakr
Feb 16, 2004

Kayak is true

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:
$(function(){
  ...
});
You can attach a "live" event as

code:
$(document).on('keyup', '.smiley-box-email input', function(){
  ...
});
With the live event handler, you'll be able to load the JS once and have it work everywhere. Add in some prototypal classes for encapsulation and you've got yourself a ujs implementation.

kayakyakr fucked around with this message at 15:30 on Aug 8, 2013

kayakyakr
Feb 16, 2004

Kayak is true

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.

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. :smithicide:

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.

kayakyakr
Feb 16, 2004

Kayak is true

DreadCthulhu posted:

Define simple? Simple for whom, for the backend or the client?

For yourself. Also the client, but mostly for yourself.

kayakyakr
Feb 16, 2004

Kayak is true
I've gone over to Rspec, with Rspec-given, Shoulda, and FactoryGirl.

When I test. That's still my greatest weakness as a programmer.

kayakyakr
Feb 16, 2004

Kayak is true

Cocoa Crispies posted:

It's very very high level integration testing: I use it as a to-do list that checks itself off. I've heard that you should write scenarios in a way that you could use the same set of scenarios for HTML, iOS, and Android versions of an application.

code:
Given I am at the login screen
When I fill in my credentials
Then I should see the dashboard

Given I am at the reply screen
When I make a post
Then I should see my post in the thread

When I was writing heavy cucumber tests, I was going with the style of writing very generic, basic commands similar to what you have written and then making the step definitions more complex.

My biggest problem with cucumber is that it's an awful idea to use for testing a heavy javascript front end. It can do it, but good lord it takes a long time. Our (moderately complex) web app took in the order of an hour to run the test suite.

Granted a lot of that could have been the terrible decision to use ExtJS.

kayakyakr
Feb 16, 2004

Kayak is true

Peristalsis posted:

I have three questions, but there's a wall o' text first.

Background:
I have to replace some existing apps that nobody likes with a Ruby on Rails web app. This app will have a back end API for other processes to send in data without going through the web pages. I'm vaguely aware of web services, and figured that would be the way to set up the API, assuming that it can be handled from the same rails server that is simultaneously handling the web app. I don't care whether I use a SOAP web service or a restful one (not entirely comfortable with the differences, but my requirements should be pretty simple database inserts and queries, so I imagine that can be done with either approach). I looked around, and it looks like the gems that let you plunk in web service functionality are old and not maintained, but that it's not supposed to be hard to do your own thing.

Current:
Working from this page, I made a GET route that can return just plain text in response to a request (which will probably be coming from curl commands in both R scripts and another Ruby script), and got a spot in my controller to render that text. I'll plan to use this to return completion codes and/or query results. I assume that setting up a post route will be similar, and that this is the way to return data to another process using the app.

My questions:
1) The requests might be quite large, involving insertion of several related and linked database rows, and will need to be parsed and processed before returning a completion code. I want to have the user pass in some XML string, or maybe a JSON construct (unless there's a better option), but I have no idea how to get that data into the controller. Should it just be a url parameter of some sort, or is there a better way to get this done?

2) Is this the right way to go about this, or should I be looking at some more formal web service setup, even if it uses outdated code? Or some other way of setting up the API entirely?

3) Ultimately, I want to restrict use to approved people, so random weirdos can't just post data to our database for fun and profit. Is there a standard way to enforce something like that? I assume we don't just want login and password data coming through GET/POST requests.

I would suggest making a standard rails app but instead of (or in addition to) html.erb files, write json.jbuilder views. Makes a pretty good web service endpoint.

You can use basic auth + https and cookies to do that or you could implement an api key/secret thing. You might look into seeing if anyone else has implemented a jsonp renderer on top of jbuilder.

kayakyakr
Feb 16, 2004

Kayak is true

Peristalsis posted:

It's in addition to, but I'm inclined to stick with XML for the first version, if only because one of the people writing the client code isn't a programmer. He's more likely to be familiar with XML than with JSON. I'm also not sure he's going to like shoe-horning curl commands into his R scripts, but I guess he'll have to get over it. I found info on RCurl for him, so at least he shouldn't have to shell out to the OS to make it work. Eventually, I'd like to allow both approaches (XML and JSON), probably through different Rails routes.

For XML use Builder:
https://github.com/jimweirich/builder

Don't use routing tricks, use the format parameter. Example:
/users => html
/users.json => json
/users.xml => xml

Rails knows, via respond_to/respond_with which views to render for each. Support all of the API languages in one shot and be happy. Use standard form posts and url params for bringing data in.

kayakyakr
Feb 16, 2004

Kayak is true

Peristalsis posted:

Edit: I've probably been unclear - for the most part, I'll be reading the XML, and parsing it. I might pass back query results in XML, as well, but my main problem is passing the client's XML into my code and parsing it.

oh, gross.

Umm, I'm still a fan of taking in data in a standard post body rather than encoded as an XML field. But there is middleware for that:
https://github.com/rails/actionpack-xml_parser

kayakyakr
Feb 16, 2004

Kayak is true

Deus Rex posted:

Anyone have thoughts on JBuilder vs. RABL for building a JSON API? I'm building an Angular app with a Rails backend and I don't think hacking around as_json is going to cut it as I've done in the past.

jbuilder is sorta the culmination of all of those that came before it. I really prefer jbuilder.

kayakyakr
Feb 16, 2004

Kayak is true

Pollyanna posted:

I'm having trouble installing recent versions of Ruby onto my OSX computer. I tried using the RVM, but it somehow managed to mess up whatever version I was using at the time. What's the most newbie-friendly recommended way to install Ruby, Rails, and whatever?

RVM is supposed to be the easiest. You install RVM, install a ruby, then run
code:
gem install bundler
gem install rails
If that doesn't work, well, I've never used it, but they advertise as the easiest way to install rails:
http://railsinstaller.org/en#osx

kayakyakr
Feb 16, 2004

Kayak is true
I hated rubymine. Way more than you could ever need and java-based so it's performance was horrible.

kayakyakr
Feb 16, 2004

Kayak is true

Smol posted:

I hope that you're not seriously as a Ruby developer complaining about Java performance.

Java GUI performance on Linux machines using any sane upper memory limit is pretty terrible. Maybe on mac, rubymine runs better? I dunno, to me it was pretty crap.

Sil posted:

tldr+warning: rails noob(?) not sure what I know, what to do next.

Reading through that, you're absolutely entry level rails. You have more experience with Rails than the last guy I hired. If you understand programming and understand how to get things done, you'll be ok.

Pollyanna posted:

Right, I forgot. :downs: So how do people make games and applications in Ruby, then? Is everything just run from the terminal?

Mostly run from terminal or started as a server. It is possible to write desktop apps in ruby, though. Ruby Toolbox is a great place to look up what sort of things people have come up with.
https://www.ruby-toolbox.com/categories/game_libraries
https://www.ruby-toolbox.com/categories/packaging_to_executables
https://www.ruby-toolbox.com/categories/GUI_Frameworks

kayakyakr
Feb 16, 2004

Kayak is true

chumpchous posted:

Question: I had a bug in my application that was causing the DB to lock up when a form got double posted. I switched to postgres and fixed some issues, but I've never actually managed to replicate the bug. The post is submitted via JSON, and I've tried just sending multiple JSON posts but it wont happen. I've also tried manually clicking the button really fast but that doesn't do it either. Still though, users are managing to pull it off. Any tips?

Were you using sqlite? Were you using a multi-instance server like unicorn? If so, that was your problem.

kayakyakr
Feb 16, 2004

Kayak is true

chumpchous posted:

Yeah I was using SQLite, and now I'm using postgres, so the problem is fixed. I just want to know how to test for the error, because I can't replicate it (on a server using an SQLite db).

The problem is sqlite is single threaded. It works until someone hits the database at the same time as someone else. If you were using unicorn, this would happen any time two requests are submitted at the same time.

You can't really test for the error, you just have to know that if you're using sqlite, you can only use one server process at a time.

kayakyakr
Feb 16, 2004

Kayak is true

EAT THE EGGS RICOLA posted:

Are there any decent ruby gems for doing decent visualizations, in the form of graphs/charts/maps/anything? I have a bunch of varied datasets that I've been asked to make interesting with, and all of my code that works with the api is ruby-based so I'd like to just carry on with that.

There isn't really one. I was working on making one, but haven't fully gemified it yet. Ran out of time.

e: this is awful code and you should by no means copy it because it breaks about 20 standard rails conventions, but this makes a pretty nice line chart:
https://github.com/talho/epi_full/blob/master/app/views/svg/line.svg.erb

kayakyakr
Feb 16, 2004

Kayak is true
For building XML responses, you could always use erb. create a view named action.xml.erb and write XML as if you were writing an HTML view.

This doesn't work as well if you're trying to send XML to a different webservice

kayakyakr
Feb 16, 2004

Kayak is true

Baron Dirigible posted:

(Edit: I think I understand now, but just to be certain: with a belongs_to: through: I need to create another model in Rails, but with has_and_belongs_to: I just need to create a join table in the migrate file / directly in mySQL?)

You are correct. habtm does not have an associated model while hmt does.

Baron Dirigible posted:

Secondly, is there a good resource out there for how to use an existing MySQL database with Rails? Everything I've seen assumes I'm setting up and migrating from scratch, but I have the database already set up and populated and just need to know how much of the structure I need to declare for Rails.

rake db:schema:dump will create a schema from the database. You'll have to create all the models manually.

kayakyakr
Feb 16, 2004

Kayak is true

Peristalsis posted:

I was confused about this recently, too.

Both habtm and hmt need and use a join table in the database, right - it's just that one doesn't use or require a corresponding Rails model? Also, you have to create the join table in both cases, don't you? I'm assuming that they only point it out in the habtm case because it would be easier to forget it, since you don't have a model for it to remind you of its existence.

habtm is a bit of that Rails magic that you must know about to use. You have to create a table in both cases, and that table must include id's from both sides of the relation. The difference is that habtm doesn't have an id for itself and there is no model for it.

I'd say that hmt doesn't use a join table because that table represents something else in your database other than just a join between the two tables. If the join between the two has no context (ie the only thing you'll ever be doing is joining the two) then the proper relationship to use is habtm. The join table is not really a reminder thing, it's necessary to make the habtm work

kayakyakr
Feb 16, 2004

Kayak is true

Cocoa Crispies posted:

This is, of course, never true unless it's the simplest throwaway project. Assigning a name, model, and behavior to the relationship between two entities not only provides for future extensibility, but it helps you understand and reason about the relationship better.

I disagree, but that's probably because I wrote SQL in my past life.

kayakyakr
Feb 16, 2004

Kayak is true
I've been using amazon's elastic beanstalk, another service that you can get free (for a year). It's ok. I mean, it's pretty poo poo because it's amazon micro, but it's ok and not hard to deploy to.

kayakyakr
Feb 16, 2004

Kayak is true

Sub Par posted:

I'm building a simple search form and trying to determine if this approach is safe from an SQL injection point of view:
code:
@users = User.where("username like ?","%#{params[:search]}%")
I can't seem to find an answer that's on point. Is there a better/safer way to accomplish this?

That should be ok. The cleaner will clean the full string out. If you get anything more complex than that, you should really look into integrating sphinx.

Peristalsis posted:

Oh, and one more question.

I think this came up with a one-to-many relationship between two models/tables, say owners and products (one owner can own many products).

If I create a new product object, and add it to an owner like this "owner1.products << my_new_product_object", then I can see the product in the products array, the next time I execute "owner1.products". However, if I just manually set "my_new_product_object.owner_id = 1", then Rails doesn't add it to owner1.products, even though, as far as I know, the net effect should be exactly the same.

Any idea what's going on here?

Did you reload owner1 between creating your new product object? Otherwise, it'll probably just cache the last products lookup. Are you use the product object is saving and are you sure that's the proper id?

kayakyakr
Feb 16, 2004

Kayak is true

Sub Par posted:

Thanks. I plan to, once I can spend some money.

what are you hosting on? we successfully ran sphinx + thinking_sphinx (rails gem) side-by-side with unicorn on a single virtual server.

kayakyakr
Feb 16, 2004

Kayak is true

Sub Par posted:

I have a proof of concept type thing up on Heroku and am just trying to drum up interest in the idea. If I can get my friends on board and put up a small amount of cash I am going to go with a VPS, but Heroku for now. Not worth even the $12/mo for the sphinx-based add-ons right now for my ~600 users.

~600 users is not bad for a proof of concept on heroku. I know a lot of people hate it, but you could get a 2 core, 40 GB VPS on digital ocean for $20/month.

Adbot
ADBOT LOVES YOU

kayakyakr
Feb 16, 2004

Kayak is true
I learned how to use capistrano not too long ago so setting up a new environment from scratch with that is two commands and about 10 minutes.

ignore the other horrible code in this project, this is a simple capistrano deploy script:
https://github.com/Yakrware/sum_times/blob/master/config/deploy.rb
plus
https://github.com/Yakrware/sum_times/blob/master/config/deploy/production.rb.example

in others I've got it installing requirements in the setup and you can script it to set up nginx or whatever you need.

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