Sign in through GitHub

Please read for an updated status on RailsCasts:

Learn more or hide this

Brett Dudo's Profile

GitHub User: dudo

Comments by Brett Dudo

Avatar

hey @ryan! I used your home brew in a rails 4 app, but the self.by_votes method doesn't seem to work. As is... it orders things, but it duplicates each item for each time they've been voted on. I was wondering if you had any ideas?

Avatar

I'm crying laughing at that xkcd comic. Let's be friends =)

Avatar

shorthand...

Gemfile
gem 'mongoid', github: 'mongoid/mongoid'
Avatar

for anyone that comes across it... the format that it needs to be in is just a string of ids, separated by commas.

ruby
incoming = ['Will E Makit', 'Betty Wont', 'Adolf Oliver Bush']
author_tokens: Author.where("name IN (?)", incoming).map{|c| c.id}.join(',')
Avatar

If I want to create a Book manually, how do I pass the Authors manually? An array doesn't seem to work. I'd basically like to do something like:

ruby
Book.create!(title: '10 yards to the Shitter', author_tokens: ['Will E Makit', 'Betty Wont'])

I need to call the create action from another model... and I can't seem to pass the author_tokens properly.

Avatar
def create
  @album = Album.find(params[:album_id])
  params[:photo][:user_id] = current_user.id
  @photo = @album.photos.build(params[:photo])
  @photo.save
end

how do I capture params[:photo][:name]?

Avatar

for the user_id, you can do params[:photo][:user_id] = current_user.id or something like that. I'm still trying to figure out how to capture the photo name...

Avatar

any further notes on this? I added 'content-type' => 'file' as a placeholder, and added the data.form.find('#content-type').val(file.type) to the coffee file above the data.submit()... nada. Images stop uploading.

but I, too, am getting the application/octet-stream warning...

Avatar

I'd like to pass a parameter to the datatable.rb... specifically, the @user = User.find(params[:id]). Side note, I'd also like to be able to use current_user in the new class. I haven't tried it, so I'm not sure if that will even work.

Thoughts?