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
tima
Mar 1, 2001

No longer a newbie
I use screen, rvm, vim with rails plugins, git and heroku.

I ve used both mate and subliminal but I work from multiple platforms and being able to ssh and work from anywhere is worth it.

I'd also like access to heroku beta apps if possible.

Adbot
ADBOT LOVES YOU

tima
Mar 1, 2001

No longer a newbie

Oh My Science posted:

I'm afraid I don't really know how to ask for this properly, but here it goes.

I would like to provide users with the ability to use different view layouts based on their user settings, what would be the best way to accomplish this? ( similar to what Facebook & twitter has done recently )

So far my google-fu has not produced many results, and after reading the API on layouts and templates I feel I may be missing something fundamental.

Edit: from the layouts and rendering guide

code:
class ProductsController < ApplicationController
  layout :products_layout
 
  def show
    @product = Product.find(params[:id])
  end
 
  private
    def products_layout
      @current_user.special? ? "special" : "products"
    end
 
end
Where it will use the layout file in your "app/views/layouts/" folder.

tima fucked around with this message at 06:12 on May 20, 2012

tima
Mar 1, 2001

No longer a newbie

plasticbugs posted:

I've decided to push my rails app to github to start building my 'portfolio'. I created a yaml file with all my configuration settings (passwords, email addresses, secret keys, etc) and added it to my .gitignore so that it wouldn't get pushed to github - revealing my passwords, etc.

My question: Now that git is ignoring my configuration settings, how do I successfully push app updates to Heroku without removing 'config.yml' from my .gitignore file?

Removing my configuration file from .gitignore, telling git to start tracking my config.yml again, THEN pushing to Heroku? Seems like that would be WAY too complicated. There must be an easier way, right? What am I missing?

For heroku you usually use environment variables instead of yml files, check out documentation for "heroku config" on how to add them to your heroku environment.

tima
Mar 1, 2001

No longer a newbie

mmachine posted:

I'm trying to understand how to implement click-to-edit functionality. I've seen some gems suggested for doing this, but since the purpose of the project I'm working now is to teach myself how to use RoR, I'd prefer to at least learn an implementation from scratch.

What I have so far is a page -- let's call it Edit Recipe -- that then allows a user to add and remove both Ingredients and Directions / Steps. I've been able to get far enough as to implemnent this functionality using AJAX, but now I've hit a wall when trying to implement a way to edit pre-existing data for each item. Say a user has entered a recipe direction -- I'd like to give them the ability to click on an edit call to action and then be able to change the content of the direction, submit and have it be saved.

Where I'm failing now is in getting the form partials -- let's use the _form for Directions as an example -- to render in the context of an Edit. So, say I have 4 directions listed, I do get a form rendered for each, though the form is for a create new direction, not an update existing.

So now, what I need to understand is what should be happpening to get those Direction forms to understand they should be appearing with the data for their respective record when they are placed into the DOM, AND also understand that on post, they are to edit their respective Direction record. The way the forms currently get placed is via a line of JavaScript that goes like this:


$('#direction_<%= direction.id %> .edit').click(function(){
$('#direction_<%= direction.id %>').append("<%= escape_javascript(render :partial => 'directions/form', :locals => { :direction => direction }) %>");
});
...and then the partial for my Direction _form (currently) looks like this:



<% if defined? direction %>

<%= form_for :direction, :url => { :action => 'edit', :id => direction.id }, :remote => true do |f| %>
<div class="input-append">
<%= f.text_field :content, :class => 'input-xlarge' %>
<%= f.submit :value => 'save', :class => 'btn' %>
</div>
<% end %>

<% else %>

<%= form_for([@recipe, @recipe.directions.build], :remote => true) do |f| %>

<div class="input-append">
<%= f.text_field :content, :class => 'input-xlarge' %>
<%= f.submit :value => 'add', :class => 'btn' %>
</div>

<% end %>

<% end %>


...where I'm trying to at least pass the Direction object along, thinking that's all the partial needs to render as an edit form. Of course now I have the problem of this not working, the form still thinking it's posting a new direction, and not editing a pre-existing one, so I'm missing something big on defining the controller resources to use for the form maybe? I was under the impression the partials would be conscious of a Direction object, and just do their thing automagically.

Lots I'm doing wrong practice wise too maybe -- for example, the contextual partial for the Direction _form seems awkward, but maybe that's the way to do this sort of thing?

EDIT: Sorry for the ugly formatting. Copypasta skills need some work too it looks like...

Have you looked at the railscasts cast on this topic? http://railscasts.com/episodes/136-jquery-ajax-revised

tima
Mar 1, 2001

No longer a newbie

Physical posted:

Where can I find info on RubyCon and other RoR convetions?

e: durrrr http://www.railsconf.com/ But are there any others?

Here is one on the west end of us http://mtnwestrubyconf.org/

tima
Mar 1, 2001

No longer a newbie
What I like to do teaching ruby is make a little game in a couple of hours that lets users work with main loop, input, output and some simple logic. I actually used both classes and testing in my game, but you can just do methods to keep it simple. Last time i did the hangman game and it was fairly fun to implement and play with afterwards.

Then next lesson you can convert it to rails version and show that main loop => rails server, input => routes, output => views, controller + model => logic.

tima
Mar 1, 2001

No longer a newbie

xtal posted:

Given an exported GPG private key and its passphrase, how can I decrypt a string encrypted with the corresponding public key? Haven't had any luck with GPG-related gems, which all seem to rely on pinentry/gpg-agent instead of a provided passphrase.

I don't know how deep you want to dig into it, but PGP/GPG uses https://tools.ietf.org/html/rfc4880 for algorithm, it should be fairly easy to implement (code wise) if you have time to dig into the math.

That said this gem looks like it doesn't have too many dependencies, although I haven't used it myself: http://openpgp.rubyforge.org/

Adbot
ADBOT LOVES YOU

tima
Mar 1, 2001

No longer a newbie

Safe and Secure! posted:

I have two models: Thread and Comment. They represent threads and posts in a typical forum - each thread has many comments, each comment belongs to a thread.

I want to have a user create a new Thread by submitting a title for the thread, and some text for the content of the comment. Here is my ThreadController#create method:

code:

  def create
    @thread = MyThread.new(my_thread_params)
    @thread.user = current_user
    @thread.board = Board.find(params[:board_id])

    comment = Comment.new
    comment.content = params[:my_thread][:comment][:content]
    comment.user = @my_thread.user
    comment.my_thread = @my_thread

    if @my_thread.save 
      if comment.save
        redirect_to @my_thread, notice: 'My thread was successfully created.'
      else
        render action: 'new'
      end
    else
      render action: 'new'
    end
  end

Obviously, this is going to give me problems when the board is valid but the comment is invalid - the board will be saved, but the comment will not be saved, so I'll have threads without any posts in them, which is not what I want. What's the non-stupid way to create both a Thread and a Comment?

Without going into the code and the design too far you can always check if my_thread.valid? and comment.valid? Then save both else render new

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