- 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.
|
#
¿
Feb 28, 2012 02:21
|
|
- Adbot
-
ADBOT LOVES YOU
|
|
#
¿
Apr 27, 2024 13:48
|
|
- 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
|
#
¿
May 20, 2012 06:09
|
|
- tima
- Mar 1, 2001
-
No longer a newbie
|
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.
|
#
¿
May 21, 2012 10:20
|
|
- tima
- Mar 1, 2001
-
No longer a newbie
|
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
|
#
¿
Oct 22, 2012 22:35
|
|
- tima
- Mar 1, 2001
-
No longer a newbie
|
Here is one on the west end of us http://mtnwestrubyconf.org/
|
#
¿
Jan 11, 2013 17:47
|
|
- 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.
|
#
¿
Jan 28, 2013 19:39
|
|
- tima
- Mar 1, 2001
-
No longer a newbie
|
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/
|
#
¿
Jul 8, 2013 01:10
|
|
- Adbot
-
ADBOT LOVES YOU
|
|
#
¿
Apr 27, 2024 13:48
|
|
- tima
- Mar 1, 2001
-
No longer a newbie
|
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
|
#
¿
Jul 31, 2013 07:08
|
|