railscasts

Nested Model Forms - Railscast #196 revised - Adding fields via jQuery not working

放肆的年华 提交于 2019-12-04 13:42:30
I was following the Railscast #196 revised and everything went basically fine, but I am not able to add new fields to the nested form. The "remove fields" function works nicely, but after click on "link_to_add_fields", the browser jumps to the top of the page, and no new field appears. There are already a ton of questions to this railscast, like here or here , and I tried to read all of them, but most of them are referring to the original casts from 2010. I am stuck for hours now, and I can't figure out, where my problem is. Sorry, if its a rookie mistake, I am quite new to rails. Any help

rails excel mime-type - how to change default filename?

五迷三道 提交于 2019-12-04 11:16:59
I followed the http://railscasts.com/episodes/362-exporting-csv-and-excel and set up an Excel Download in my Rails application. My controller code looks like this: def show @project = Project.find(params[:id]) @project.tasks.order(:name) respond_to do |format| format.html format.json { render json: @project } format.xls end end and in my view I create the link to download the excel file like this: .dl_xls= link_to "Download xls", url_for(:format => 'xls') Now the generated excel file is always named like the id of the Project record, e.g. 80.xls Is there any way to change this behaviour and

undefined method `key?' for nil:NilClass

空扰寡人 提交于 2019-12-04 09:02:31
I'm new to Rails and was following Ryan Bate's tutorial on how to make a simple authentication system ( http://railscasts.com/episodes/250-authentication-from-scratch?autoplay=true ) and I was just going through it but got this error: ` NoMethodError in UsersController#new undefined method `key?' for nil:NilClass Rails.root: C:/Sites/authentication` I don't really know what this means since I'm just a beginner, but these are my files: users controller: class UsersController < ApplicationController def new @user = User.new end def create @user = User.new(params[:user]) if @user.save redirect_to

Private messages with Faye and Rails

99封情书 提交于 2019-12-03 19:22:31
I'm using the faye gem menitioned in the railscast allowing apps to push messages. Problem is it pushes messages to all chat clients that are open. I need them to be private. It's possible to get private messaging with faye but it's url based. For example all messages will be sent to site.com/foo . But, in my model the chat doesn't have a specific url. Because chat is just a collection of messages sent to you by that user. So if you're logged in as adam site.com/messages/eve would allow you to talk to eve but for eve it's the reverse. site.com/messages/adam . So URL specific private chat is

Display a Twitter feed from a Rails app

僤鯓⒐⒋嵵緔 提交于 2019-12-03 09:59:31
问题 I have been able to have a user sign in with Twitter via OmniAuth (I followed Railscast #235-6 and made a simple application). Now I am trying to display the Twitter feed of the logged in user. Can anyone tell me how this is done? How do I initialize Twitter? How do I pass in the username and password of the logged in user? I am new to Rails so it would be helpful if I knew exactly where to put the code. Thanks 回答1: First, you don't need user credentials to get a Twitter feed if it's public.

Adding dynamic fields to nested form through AJAX

时光怂恿深爱的人放手 提交于 2019-12-03 02:54:25
I've been watching and reproducing these railscasts on my app: 196-nested-model-form-part-1 and 197-nested-model-form-part-2 . I do not yet have a pro account so i can't watch the revised episode. I'm developing under rails4 (edge) and link_to_function has been deprecated in favor of unobstrusive JS (which is great). I'll keep the example of the above railscasts (i.e. survey/question). What i'd like to do is to use the question's partial through unobstrusive javascript and i just don't know how and where i should do this. I was thinking of two ways to do so : First way would be to add in my

Railscasts Episode #362 - Exporting to Excel: How to avoid the warning message given by Excel 2010 when opening the file?

我与影子孤独终老i 提交于 2019-12-01 17:17:16
When using the example app from Ryan Bates' Railscasts Episode #362 about exporting to Excel ( https://github.com/railscasts/362-exporting-csv-and-excel ), I've noticed that Excel 2010 (which is on Windows) gives me a warning message when opening up the .xls file I've downloaded using the "Download as Excel" link. The warning reads: "The file you are trying to open ... is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted source before opening the file. Do you want to open the file now?" I can open the file just fine when I

DangerousAttributeError in OmniAuth Railscast Tutorial: create is defined by ActiveRecord

只愿长相守 提交于 2019-12-01 16:09:27
I've looked at ActiveRecord::DangerousAttributeError and other similar threads on SO, but they don't address the same issue. I'm following the omniauth tutorial: http://railscasts.com/episodes/235-omniauth-part-1?view=asciicast I'm able to authenticate via oauth with Twitter and return the user's data (auth). The problem is that I'm not able to create/save it in the database (sqlite3) because of this error message. Error: ActiveRecord::DangerousAttributeError in AuthenticationsController#create create is defined by ActiveRecord Rails.root: /beta/devise-omniauth1 Application Trace | Framework

DangerousAttributeError in OmniAuth Railscast Tutorial: create is defined by ActiveRecord

安稳与你 提交于 2019-12-01 15:57:27
问题 I've looked at ActiveRecord::DangerousAttributeError and other similar threads on SO, but they don't address the same issue. I'm following the omniauth tutorial: http://railscasts.com/episodes/235-omniauth-part-1?view=asciicast I'm able to authenticate via oauth with Twitter and return the user's data (auth). The problem is that I'm not able to create/save it in the database (sqlite3) because of this error message. Error: ActiveRecord::DangerousAttributeError in AuthenticationsController

Using jquery TokenInput without default 'name'

被刻印的时光 ゝ 提交于 2019-11-30 23:37:46
Im trying to use the jquery tokeninput found here: http://loopj.com/jquery-tokeninput/ Following the guide from railcasts: http://railscasts.com/episodes/258-token-fields By default, it required a 'name' column on the table/json.. Any way to customize to change it to something else (in my case, 'account_number')? (in the reailcast, he says if you dont have a 'name' column, youll require extra customization) The magical lines are <%= f.text_field :author_tokens, "data-pre" => @book.authors.map(&:attributes).to_json %> and format.json { render :json => @authors.map(&:attributes) } These lines