Search Results

Search found 9437 results on 378 pages for 'rails newbie'.

Page 71/378 | < Previous Page | 67 68 69 70 71 72 73 74 75 76 77 78  | Next Page >

  • Serialized form fields in Ruby on Rails problem

    - by Violet
    I'm having a problem making serialized columns in my model persist correctly in forms. If my model validation fails I want to redisplay the "new" page with all my model data still in the forms. Right now, everything except the serialized fields seem to persist (if my Order fails to purchase, on the "new" page the email is still filled in but the shipping address fields are not). Is this a Rails bug or am I doing something wrong? My model: class Order < ActiveRecord::Base serialize :shipping_address end My controller: def new @order = Order.new end def create @order = Order.new params[:order] if @order.purchase then render :action => "success" else render :action => "new" end end My view, new.html.haml: = form_for @order do |f| - if @order.errors.any? #errorExplanation %p The following errors occurred: %ul - for msg in @order.errors.full_messages %li= msg %h2 Billing Information = f.label :email = f.text_field :email %h2 Shipping Address = f.fields_for :shipping_address do |b| %p.field.address = b.label :address1 = b.text_field :address1 %p= f.submit "Place Order"

    Read the article

  • Which testing method to go with? [Rails]

    - by yuval
    I am starting a new project for a client today. I have done some rails projects before but never bothered writing tests for them. I'd like to change that starting with this new project. I am aware there are several testing tools, but am a bit confused as to which I should be using. I heard of RSpec, Mocha, Webrat, and Cucamber. Please keep in mind I never really wrote any regular tests, so my knowledge of testing in general is quite limited. How would you suggest I get started? Thanks!

    Read the article

  • losing session in rails 2.3.2 app using subdomain

    - by mike in africa
    i have a 2.2.3 app which i upgraded to 2.3.2 it's a multi-site (using subdomain) that creates one top level session for all sites. this is how i change the domain in production.rb: ActionController::Base.session_options[:domain] = "xxx.com" # in rails 2.2.2, this is what i used to do: # ActionController::Base.session_options[:session_domain] = "xxx.com" strange things started to happen after i upgraded i can no longer login using restful authentication; it does authenticate me, but as soon as i'm redirected, it would ask me to login again. as i said, i use restful_authentication and i also use passenger 2.1.2. anyone can help?

    Read the article

  • problems to setup the ruby on rails facebooker plugin

    - by fenec
    i am developing a facebook application with rails and the facebooker plugin from my local machine and have problems to set it up. here is my facebooker.yml file enter code here development: api_key: myAPIKey secret_key: mySecretKey canvas_page_name: http://apps.facebook.com/rafikbennacer/ callback_url: http://207.172.82.237:3000 pretty_errors: true set_asset_host_to_callback_url: true tunnel: public_host_username: public_host: public_port: 4007 local_port: 3000 server_alive_interval: 0 I got my Callback URL accessible from the outside by doing a port forwarding on my router, everything seems to work but i still have this message error when i go to http://apps.facebook.com/rafikbennacer/: Errors while loading page from application Received HTTP error code 404 while loading http://207.172.82.237:3000/ Please try again later. We appreciate your patience as the developers of test1 and Facebook resolve this issue. Thanks! where am i wrong in my configuration , how can i trouble shoot this error? thank you

    Read the article

  • Some questions about setting up Amazon S3 with Ruby on Rails

    - by ben
    I'm trying to setup Amazon S3 hosting with my Ruby on Rails 3 app, which is hosted on Heroku. After reading these instructions in the Heroku docs, I'm trying to use the aws-s3 gem. The instructions say to put the S3 account details in config/amazon_s3.yml, but the aws-s3 Github page says you create a connection like this: AWS::S3::Base.establish_connection!( :access_key_id => 'abc', :secret_access_key => '123' ) Why is the connection created by providing the details if they're already provided in the config file? Is that not the correct way to establish a connection? Do I have to establish a connection for each user everytime an upload is about to occur, or is a connection established for the application as a whole? Thanks for reading.

    Read the article

  • 403 Error when Authenticating using tumblr gem for rails application

    - by Matenia Rossides
    I have a ruby-on-rails application that wishes to utilise the tumblr gem for adding posts when an action is taken (eg: creating a blog post) I currently have the tumblr gem installed and can manage to fetch my posts using @tumblruser = Tumblr::User.new('myemail','mypassword') However when i go to add a post where it asks me to pass the user information like so (according to the API for the gem) post = Tumblr::Post.create(@tumblruser, :type => 'video', :embed => @post.video_html, :title => @post.title, :caption => @post.content) it just does not want to authenticate and returns a 403 error anyone had any experience with this?

    Read the article

  • Rails - building an absolute url in a model's virtual attribute without url helper

    - by Nick
    I have a model that has paperclip attachments. The model might be used in multiple rails apps I need to return a full (non-relative) url to the attachment as part of a JSON API being consumed elsewhere. I'd like to abstract the paperclip aspect and have a simple virtual attribute like this: def thumbnail_url self.photo.url(:thumb) end This however only gives me the relative path. Since it's in the model I can't use the URL helper methods, right? What would be a good approach to prepending the application root url since I don't have helper support? I would like to avoid hardcoding something or adding code to the controller method that assembles my JSON. Thank you

    Read the article

  • Combining Two Models in Rails for a Form

    - by matsko
    Hey Guys. I'm very new with rails and I've been building a CMS application backend. All is going well, but I would like to know if this is possible? Basically I have two models: @page { id, name, number } @extended_page { id, page_id, description, image } The idea is that there are bunch of pages but NOT ALL pages have extended_content. In the event that there is a page with extended content then I want to be able to have a form that allows for editing both of them. In the controller: @page = Page.find(params[:id]) @extended= Extended.find(:first, :conditions = ["page_id = ?",@page.id]) @combined = ... #merge the two somehow So in the view: <%- form_for @combined do |f| % <%= f.label :name % <%= f.text_field :name % ... <%= f.label :description % <%= f.text_field :description % <%- end This way in the controller, there only has to be one model that will be updated (which will update to both). Is this possible?

    Read the article

  • Rails: Display Maintenance Page if No Database Connection Available

    - by RobB
    I'm looking for a solution that will allow my rails app to render a user-friendly maintenance page when there is no Mysql server available to connect to. Normally a Mysql::Error is thrown from the mysql connection adapter in active_record. Something like: /!\ FAILSAFE /!\ Wed May 26 11:40:14 -0700 2010 Status: 500 Internal Server Error Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' Is there a low-overhead way to catch this error and render a maintenance page instead? I'm assuming that since connections are actually made in the active_record mysql adapter the app never makes it to the controller stack before it throws the error, so you can't catch it in a controller. Any input would be greatly appreciated.

    Read the article

  • Rails Mikel Mail Gem How to use Views

    - by Victor Martins
    I'm trying to use mikel gem mail on my 2.3.5 Rails App http://github.com/mikel/mail I have it working like this. I've made a MailComHelper, made a method like this : def self.welcome(user,password) @user = user m = Mail.new m.from = '[email protected]' m.to = @user.email m.subject = 'welcome' m.body = 'The body' m.delivery_method :sendmail m.deliver! end And it works, I receive the mail. But I wish I could use the old way of calling a view ( html.erb ) file and send that code has the body. I've read the documentation but haven't found a way to do it. Has anyone found a way to do it?

    Read the article

  • Rails: how do you access RESTful helpers?

    - by Ethan
    I'm trying to work through this guide to Rails routing, but I got stuck in section 3.3: Creating a RESTful route will also make available a pile of helpers within your application and then they list some helpers like photos_url, photos_path, etc. My questions: Where can I find the complete list of helpers that is "made available?" Is there a way to call the helpers in the console? I created an app, then opened up the console with script/console. I tried to call one of the helpers on the console like this: >> entries_url But got: NameError: undefined local variable or method `entries_url' for #<Object:0x349a4> from (irb):8

    Read the article

  • Form to sort an index in rails

    - by shmichael
    I'm a newcomer to Rails. I want to build a simple form that determines the sort order of a list. I've implemented a form in the likes of - <%= radio_button_tag :sort, "rating" %> <%= label_tag :sort_rating, "order by rating" %> <%= radio_button_tag :sort, "name" %> <%= label_tag :sort_name, "order by name" %> And now I am unsure how to implement the sort at the controller/model level. The aspects I am puzzled about are: Where should the sort be performed How could the sort parameter be persisted How could the code be reused Right now, I can't even get the selected sort method to remain selected after a submit. I would most appreciate any guidance or reference to an example.

    Read the article

  • Rails HABTM Scoping to current subdomain

    - by Rabbott
    I have the following associations: class User < ActiveRecord::Base has_and_belongs_to_many :brands, :join_table => 'brands_users' has_and_belongs_to_many :companies, :join_table => 'companies_users' end class Brand < ActiveRecord::Base belongs_to :company has_and_belongs_to_many :users, :join_table => 'brands_users' end class Company < ActiveRecord::Base has_and_belongs_to_many :users, :join_table => 'companies_users' has_many :brands, :order => :name end While editing a user I am using the checkbox list of brands. So that I can assign users 'access' to brands, the brands that show up are only the brands that belong to the current company (defined by the subdomain [using subdomain_fu]). The problem I am running into is that when using the default HABTM functionality and the checkbox list, upon save, Rails removes ALL user-brand associations, then re-adds just the ones for the form I just submitted.. How do I scope that to only remove associations of brands who belong to the current company, defined in the subdomain?

    Read the article

  • Rails best practice on conditional parameters in a controller action

    - by randombits
    I have a controller create action looks for one or more parameters in the following ruleset. Let's say we have two parameters, foo and bar. The rules are the following: 1) if foo doesn't exist in the parameter list, bar must. 2) if bar doesn't exist in the parameter list, foo must. 3) they can both co-exist. they can't both be omitted (that's redundant with my rules above :) ) Can anyone show an example in Rails on how this is handled in the controller? Should I use a before_filter? Would appreciate some guidance as this isn't something that ActiveRecord validates.. so I'd need to build an error message to the user directly from controller logic, not model logic. For bonus points, I output the error in XML, so if you can show how that's done, that'd be great. Hypothetically let's call the resource "Lorem", so it is created via http://foo/lorem.xml and we have lorem_controller.rb.

    Read the article

  • haml / rails: yield title with german umlauts

    - by Maxem
    Hi, I would like to do something like this in my application layout: %title= "#{yield(:sub_title)} - Page Name" and in a real view - content_for :sub_title do Übersicht # I tried &Uuml;bersicht, != "&Uuml;bersicht" and a bunch of other methods what happens is, I either get the black pound with the question mark in it - wrong encoding or the raw string (&UumI;bersicht). Does anyone know a way how to get this to work? Another requirement is that I'd like to show user generated content in the title and this content may or may not have umlauts in it. Used versions: Haml 3.0.11, Rails 3 beta4 and currently for development JRuby 1.5

    Read the article

  • Can rails test speed be increased?

    - by Sam
    Hi all, I'm a recent convert to TDD but as my codebase grows in size and complexity, I find myself waiting longer and longer periods for the framework to load every time I want to run a test. I am aware of rspec's spec_server but I'm using Test::Unit with shoulda. I tried Snailgun (http://github.com/candlerb/snailgun) but noticed very little increased in speed. I have also tried spork-testunit (http://github.com/timcharper/spork-testunit) but it's not fully compatible with my existing tests. The delay in running tests is a definite pain point and is putting me of TDD (at least with rails). Is anyone aware of any other options? thanks Sam

    Read the article

  • Rails Asset Caching Breaks First few page loads

    - by Brian Armstrong
    We're using Rails asset caching for JS and CSS like this: <%= javascript_include_tag :defaults, 'autocomplete', 'searchbox', 'jqmodal', :cache => set_asset_cache(:admins) %> In our deploy we call rake tmp:assets:clear each time. The problem is that the first few page loads after a deploy come up with no css on the page. I guess until the cached all.js and all.css have been regenerated. We deploy many times per day and this is scary for any users who happen to come across a busted page. Have people found any way to make this smoother so the new cached assets are guaranteed to be there on the first new page load?

    Read the article

  • ruby / rails boolean method naming conventions

    - by Dennis
    I have a short question on ruby / rails method naming conventions or good practice. Consider the following methods: # some methods performing some sort of 'action' def action; end def action!; end # some methods checking if performing 'action' is permitted def action?; end def can_action?; end def action_allowed?; end So I wonder, which of the three ampersand-methods would be the "best" way to ask for permissions. I would go with the first one somehow, but in some cases I think this might be confused with meaning has_performed_action?. So the second approach might make that clearer but is also a bit more verbose. The third one is actually just for completeness. I don't really like that one. So are there any commonly agreed-on good practices for that?

    Read the article

  • Use javascript variables in Rails view helpers

    - by Horacio
    Using jqGrid I want to generate delete links for each row in the grid. The standard way to do this is to add the links in the gridComplete callback like shown below: gridComplete: function() { var ids = jQuery("#jobs_table").jqGrid('getDataIDs'); for(var i=0;i < ids.length;i++){ var cl = ids[i]; be = '<%= link_to(image_tag("delete.gif", :border=>0, :size=>"20x22", :alt => "delete"),· { :action => 'destroy', :id => 'cl', :method => :delete}, :class => 'ajax') -%>'; jQuery("#jobs_table").jqGrid('setRowData',ids[i],{workflow_state:be}); } }, Using getDataIDs I get a list of IDs that I can use to generate the delete links. The problem is that this is a javascript call that results in a javascript variable. The question is how can I use this variable "cl" inside rails link_to view helper?

    Read the article

  • Rails + Dragonfly gem: Saving image in a directory structure based on ActiveRecord object attributes

    - by Allen Bargi
    I'm using dragonfly gem to manage images and attachments in my rails app and I need to store images in a specific directory structure based on my user model. let' say I have user model which has a name and each user has many albums, which have a name also, then I want the images to be stored in "#{RAILS_ROOT}/public/system/#{user.name}/#{user.album.name}/#{suffix}" I've managed to changed the root_path in dragon fly and I even overrided relative_storage_path like this: class MyDataStore < Dragonfly::DataStorage::FileDataStore private def relative_storage_path(suffix) "#{suffix}" end end but still, I don't know how I can pass the ActiveRecord object attributes like user.name and user.album.name to relative_storage_path to create my ideal path. do you have any idea how I can do such a thing?

    Read the article

  • Rails messing up with HTTP POST Params

    - by Julien Genestoux
    Our app provides an API that people can use to submit URLs like this: curl -X POST http://app.local/resource -d'url=http://news.google.com/newshl=en&q=obama&um=1&ie=UTF-8&output=rss' Unfortunately, it seems that Rails messes up with this param. Any idea on how to fix this? See the log below : Processing ApplicationController#index (for 127.0.0.1 at 2010-06-08 19:03:09) [POST] Parameters: {"um"=>"1", "url"=>"http://news.google.com/newshl=en", "output"=>"rss", "q"=>"obama", "ie"=>"UTF-8"} I would expect the following : Parameters: {"url"=>"hhttp://news.google.com/newshl=en&q=obama&um=1&ie=UTF-8&output=rss"}

    Read the article

  • Plural to Singular conversion trouble in Rails Migrations?

    - by Earlz
    Hi, I'm a beginner at Ruby On Rails and am trying to get a migration to work with the name Priorities So, here is the code I use in my migration: class Priorities < ActiveRecord::Migration def self.up create_table :priorities do |t| t.column :name, :string, :null => false, :limit => 32 end Priority.create :name => "Critical" Priority.create :name => "Major" Priority.create :name => "Minor" end def self.down drop_table :priorities end end This results in the following error though: NOTICE: CREATE TABLE will create implicit sequence "priorities_id_seq" for serial column "priorities.id" NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "priorities_pkey" for table "priorities" rake aborted! An error has occurred, this and all later migrations canceled: uninitialized constant Priorities::Priority Is this some problem with turning ies to y for converting something plural to singular?

    Read the article

  • Parsing a CSV File to a Rails Database

    - by Schroedinger
    G'day guys, I'm using fasterCSV and a rake script to parse a csv with about 30 columns into my rails db for a 'Trade' item. The script works fine when all of the values are set to strings, but when I change it to a decimal, int or other value, everything goes to hell. Wondering if fasterCSV has built in int etc parsing or whether I'll have to manage these within my model. Basically, I'm given a giant amount of trades data, need to import it, and then need to provide feedback with say the average trade volume, the times, etc. I understand I can do that all with the wonderful records provided to me by activeRecord but wondered if there was an easier way to populate a rather large Database with a given CSV? Several of the fields don't have values for certain rows, fasterCSV seems to work perfectly when they're all strings, but not when I try to get decimal or other.

    Read the article

  • Rearranging parts of the URL result from link_to in Rails

    - by mathee
    This is how I'm doing it now: link_to "Profile", :controller => "profiles", :action => "asked", :id => @profile # => <a href="/profiles/asked/1">Profile</a> Does it make more sense for the URL to be <a href="/profiles/1/asked">Profile</a>? Profile 1 asked some number of questions, so it makes more sense to me for the URL to look like: /:controller/:id/:action. If you agree, how do I accomplish this? If you don't agree, please let me know why. (I'm new to Ruby on Rails, so I'm still getting used to MVC conventions.) Any advice would be great!

    Read the article

  • Auto update CSS from SASS/SCSS in Rails?

    - by Vulgrin
    Maybe I'm confused on how SASS/SCSS works within Rails (2.3.8.) but I was under the impression that if I included the option Sass::Plugin.options[:always_update] = true that whenever I changed my SCSS file and then hit the page (controller) again, the SCSS would recompile. I can't seem to get this to work, and can't seem to find a good tutorial / example for it. I've tried setting the above property in the Environment.rb file, but it didn't seem to do anything. I tried putting it in its own initializer with require 'sass' but that doesn't seem to work either. What am I missing? Or am i just forced to keep a terminal open with a sass --watch command running to be able to rapidly debug / change my styles? thx

    Read the article

< Previous Page | 67 68 69 70 71 72 73 74 75 76 77 78  | Next Page >