Search Results

Search found 7430 results on 298 pages for 'rabbit on rails'.

Page 6/298 | < Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >

  • Rails "NoMethodError" with sub-resources

    - by Tchock
    Hi. I'm a newbie Rails developer who is getting the following error when trying to access the 'new' action on my CityController: undefined method `cities_path' for #<#<Class:0x104608c18>:0x104606f08> Extracted source (around line #2): 1: <h1>New City</h1> 2: <%= form_for(@city) do |f| %> 3: <%= f.error_messages %> 4: 5: <div class="field"> As some background, I have a State model with many Cities. I'm getting this error after clicking on the following link coming from a State show page: <p>Add a city: <%= link_to "Add city", new_state_city_path(@state) %></p> When I run 'rake:routes' it says this is a legit route... For more background, here is the CityController 'new' action: def new @city = City.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @city } end end Here is the (complete) form in the view: <%= form_for(@city) do |f| %> <%= f.error_messages %> <div class="field"> <%= f.label :name %><br /> <%= f.text_field :name %> </div> <div class="actions"> <%= f.submit %> </div> <% end %> This initially made me think that it's a resources/routes issue since it came back with a mention of 'cities_path' (in fact, that's what another person posting to Stack Overflow had wrong (http://stackoverflow.com/questions/845315/rails-error-nomethoderror-my-first-ruby-app). However, that doesn't seem to be the case from what I can see. Here are how my resources look in my routes file: resources :states do resources :cities end I can get it working when they are not sub-resources, but I really need to keep them as sub-resources for my future plans with the app. Any help would be very much appreciated, since I've been racking my brains on this for more hours than I would care to admit... Thanks! (Not sure this matters at all, but I'm running the very latest version of Rails 3 beta2).

    Read the article

  • Add JSON support to Rails app

    - by Meltemi
    I am experimenting with Rails and was wondering what's needed to allow/add support for JSON requests? I have a vanilla installation of Rails 2.3.5 and the default scaffolding seem to provide support for HTML & XML requests but not JSON. class EventsController < ApplicationController # GET /events # GET /events.xml def index @events = Event.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @events } end end # GET /events/1 # GET /events/1.xml def show @event = Event.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @event } end end ... I'm new to this but it would appear as though i would need to add a format line in each method along the lines of: format.js { render :js => @event.json } couldn't this be done automatically? perhaps there's a template somewhere i need to update...or a flag i can set? Or perhaps, and most likely, I've missed the boat entirely?!?

    Read the article

  • FBML in Rails views using Facebooker

    - by ewakened
    Hi all, I have successfully wired up a Facebook Connect application and everything is working fine. I can sign new users up with Facebook, or I can link existing users with Facebook. No problems there. However, now I am trying to add an Invite page, where a user can see which of their Friends have the application, and then show them a Facebook FMBL Multi Select form to invite friends into it. Here is the documentation for that FBML tag. http://wiki.developers.facebook.com/index.php/Connect/Integrating_an_Invite_Form_into_Your_Website#Creating_a_Full_Multi-friend_Selector_Request_or_Invite However, I cannot get this to work within my Rails view. Do I need to setup something special to use FBML in my Rails views? THIS IS NOT A CANVAS Application, meaning I want people to come to my site and not visit the page through facebook, but I feel like I am missing something. Thank you! Kent

    Read the article

  • Rails - authoritative source for your database schema?

    - by keruilin
    I have Rails app, and every once in a while, when I bring new developer onboard they exclaim that they should be able to produce the current DB schema in their dev environment by running the whole history of the migrations. I personally don't think that migrations is the authoritative source for your schema. Right now what we do is load a production copy of the DB, with the current schema, onto the dev machine. And, from there, the schema can be maintained via incremental migrations. So my question are: What is the authoritative source of your schema on a Rails project? What is now considered the best-practice way to maintain your DB schema?

    Read the article

  • how to tell Rails RSpec that spec is "type helper"

    - by equivalent8
    I wrote *simple_form* input extension that is located in app/inputs/something_input.rb I'm trying to write RSpec for this. When I put this spec inside spec/helpers/application_helper_spec.rb everything was working without single problem. # spec/helpers/application_helper_spec.rb require 'spec_helper' describe ApplicationHelper do it do helper.simple_form_for @foo,:method=>'get', :url=>helper.users_path do |f| f.input :created_at, :as =>:custom_datepicker end.should =~ /something/ end end Now I'm trying to move that spec to spec/inputs/something_input_spec.rb so it will be similar name path. # spec/imputs/something_input_spec.rb require 'spec_helper' describe SomethingInput do it do helper.simple_form_for @foo,:method=>'get', :url=>helper.users_path do |f| f.input :created_at, :as =>:custom_datepicker end.should =~ /something/ end end # #ERROR: undefined local variable or method `helper' for #<RSpec::Core::ExampleGroup the thing I want to tell RSpec to threat this file as type helper spec, so I will have helper method availible with all the RSpec::Rails::HelperExampleGroup functionality ... how can I do that ?? I was trying to extend/include it with RSpec::Rails::HelperExampleGroup nothing seems to work

    Read the article

  • Extracting a Rails application into a plugin or engine

    - by Globalkeith
    I have a Rails 2.3 application which I would like to extract into a plugin, or engine. The application has user authentication, and basic cms capabilities supported by ancestry plugin. I want to extract the logic for the application into a plugin/engine so that I can use this code for future projects, with a different "skin" or "theme" if required. I'm not entirely sure I actually understand the difference between plugin and engine concepts, so that would be a good first point. What is the best approach, are there any good starting points, links, explanations, examples that I should follow. Also, with the release of R3 to consider, is there anything that I should be aware of for that, with regards to plugins etc. I am going to start off by watching Ryan's http://railscasts.com/episodes/149-rails-engines but obviously thats over a year old now, so one of the challenges I'm faced with is finding the most up to date and relevant information on this subject. All tips and help gratefully received.

    Read the article

  • rails code within javascript

    - by Jesse
    I am trying to use some rails code withing a javascript and need to have that rails code be dynamically changed. Here's the line of code: $(this).replaceWith("<%= escape_javascript(render(:partial => 'shared/products')) %>"); The 'shared/products' is the part I want to change based off information passed earlier in the javascript. How do I insert a value from javascript so that instead of 'shared/products' the products portion can be a variable? Hope this makes sense. I'm not the most experienced jQuery/javascript programmer, so any help is very much appreciated. Thanks in advance!

    Read the article

  • Rails 4.2: "Assets should not be requested directly without their digests"

    - by Nowaker
    On Rails 4.2.0.beta1 I get an error: Assets should not be requested directly without their digests: Use the helpers in ActionView::Helpers to request fonts/source-sans-pro.woff The stylesheet: @font-face { font-family: 'Source Sans Pro'; font-style: normal; font-weight: 400; src: local('Source Sans Pro'), local('SourceSansPro-Regular'), url(/assets/source-sans-pro.woff) format('woff'); } The configuration is: config.serve_static_assets = true config.assets.js_compressor = :uglifier config.assets.compile = true config.assets.digest = true config.assets.version = '1.0' config.assets.paths << Rails.root.join('app', 'assets', 'fonts') config.assets.precompile += %w(.svg .eot .woff .ttf) Sure I can disable digests and it works again, but I'm interested in using them. Therefore, how do I make use of digests when I need to request source-sans-pro.woff? Please note that I place the fonts in assets/fonts directory, not the public/ directory. I don't see a difference between images and fonts, so I want to keep them under the same directory - app/assets.

    Read the article

  • Incorporation of YUI 3 in rails

    - by lorefnon
    I was wondering if any effort has been made towards integration of YUI3 with rails asset pipeline. By integration, I don't just mean a couple of helpers for including the library but rather a complete integration of YUI module loader. I'll elaborate the idea in detail: Currently, developers developing modules using YUI rely on Ant tasks for concatenating the module components and wrapping them up with some associated metadata and generating target files ( and optionally minifying and running jslint). Also, when fetching the modules, the YUI loader calculates the module dependencies and generates a single file comprising of all the dependencies which havent been included already in the page. I was wondering if the whole functionality could be seamlessly integrated into the Asset pipeline of rails.

    Read the article

  • Create or override Rails Active Record macros (

    - by Jocelyn
    In a Rails app, Active Record creates created_at and updated_at columns thank to macros, (it seems to be also called "magic columns"). See Active Record Migrations I have some questions about that mecanism: Is it possible to override that to get a third column (e.g. deleted_at) ? Is it possible to create a new macro t.publishing that will create publish_up and publish_down columns, for example? And where to code that? Obviously, I know I can add those columns manually, but I wonder how to achieve it with macros. Working on Rails 4.

    Read the article

  • rails gem share_counts GET method on object?

    - by jaqbyte
    created the first rails app! excinting! for two weeks now I did Zombie, rubymonk etc. I love it! I used scaffold form url:string and included the gem share_counts. rails c: f = form.first ShareCounts.twitter f.url works! but... I have trouble to write the controller and the view! For you experienced railies this is probably a silly question, and probably only 5 lines of code, but for me thats a big step learning RoR! I am very thankful if someone could help how I can show the count next to the "url" field. Thank you so much!!! joh

    Read the article

  • Rails vs. Drupal [closed]

    - by joker13
    I was querying indeed.com/salary to investigate general market trends. When comparing ruby on rails with drupal, you would observe a substantial difference between these two. I'm not sure if the data on indeed.com is reliable or not but I'd appreciate your comments if you have ever tried both rails and drupal. Actually I am a .net developer considering an alternative to my asp.net mvc skills and I like to learn some non-microsoft web programming skills as well.

    Read the article

  • Rails 2.3.2 trying to render ERB instead of HAML

    - by c00lryguy
    Rails is suddenly trying to render ERB instead of Haml and I can't figure out why. I've created new rails projects, reinstalled Haml, and reinstalled Rails. Here's exactly the steps I take when making my application (Rails 2.3.2): rails> rails test rails> cd test rails\test> haml --rails . rails\test> ruby script\generate model user email:string password:string rails\test> ruby script\generate controller users index rails\test> rake db:migrate Here's what the UsersController looks like: class UsersController < ApplicationController def index @users = User.all end end My routes: ActionController::Routing::Routes.draw do |map| map.resources :users end I now create views\users\index.html.haml: %table %th(style="text-align: left;") %h1 Users - for user in @users %tr %td= user.email %td= user.password Annnd run the server... I navigate to localhost:3000\users and I get this error message: Template is missing Missing template users/index.erb in view path app/views For some reason Rails is trying to find and render .erb files instead of .haml files. vendor\plugins\haml\init.rb exists, untouched. I've reinstalled Haml (Pretty Penny) multiple times and still get the same results. I've also tried adding config.gem 'haml' to my environment.rb but this also doesn't work. I can't figure out why suddenly rails will not render haml for me.

    Read the article

  • Installing Rails on Mountain Lion

    - by Jordan Medlock
    I was wondering if you could help me find why I cannot install Ruby on Rails on my MBP with OS X Mountain Lion. It's a weird problem and I'll give you as much info as I can. I've installed ruby and it's working at version 1.9.3 And I've installed ruby gems and it's worked for every other gem I've tried to install. It's version is 1.8.24 When I run $ sudo gem install rails it replies with the message: Successfully installed rails-3.2.8 1 gem installed Although when I ask it rails -v it returns: `Rails is not currently installed on this system. To get the latest version, simply type: $ sudo gem install rails You can then rerun your "rails" command.` What should I do? The rails bash file (/usr/bin/rails) contains: #!/usr/bin/ruby # Stub rails command to load rails from Gems or print an error if not installed. require 'rubygems' version = ">= 0" if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then version = $1 ARGV.shift end begin gem 'railties', version or raise rescue Exception puts 'Rails is not currently installed on this system. To get the latest version, simply type:' puts puts ' $ sudo gem install rails' puts puts 'You can then rerun your "rails" command.' exit 0 end load Gem.bin_path('railties', 'rails', version) That must mean that the gem files aren't there or are old or corrupted How can I check that?

    Read the article

  • Trying to use a authlogic-connect as a plugin in place of gem - Server doesn't start

    - by Arkid
    I am trying to use Authlogic-connect as a plugin in Rails 3 in place of a gem. I have made an entry in the gemfile as gem "authlogic-connect", :require => "authlogic-connect", :path => "localgems" Now when I run the bundle install, it runs fine. When I try to start the server i get the error Could not find gem 'authlogic-connect (>= 0, runtime)' in source at localgems. Source does not contain any versions of 'authlogic-connect (>= 0, runtime)' Try running `bundle install`. I have placed the unzipped Gem renamed as authlogic-connect in the localgems folder. what is the problem? Here is what I get on using rails plugin install arkidmitra$ rails plugin install git://github.com/viatropos/authlogic-connect.git Usage: rails new APP_PATH [options] Options: [--skip-gemfile] # Don't create a Gemfile -d, [--database=DATABASE] # Preconfigure for selected database (options: mysql/oracle/postgresql/sqlite3/frontbase/ibm_db) # Default: sqlite3 -O, [--skip-active-record] # Skip Active Record files [--dev] # Setup the application with Gemfile pointing to your Rails checkout -J, [--skip-prototype] # Skip Prototype files -T, [--skip-test-unit] # Skip Test::Unit files -G, [--skip-git] # Skip Git ignores and keeps -r, [--ruby=PATH] # Path to the Ruby binary of your choice # Default: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -m, [--template=TEMPLATE] # Path to an application template (can be a filesystem path or URL) -b, [--builder=BUILDER] # Path to an application builder (can be a filesystem path or URL) [--edge] # Setup the application with Gemfile pointing to Rails repository Runtime options: -q, [--quiet] # Supress status output -s, [--skip] # Skip files that already exist -f, [--force] # Overwrite files that already exist -p, [--pretend] # Run but do not make any changes Rails options: -h, [--help] # Show this help message and quit -v, [--version] # Show Rails version number and quit Description: The 'rails new' command creates a new Rails application with a default directory structure and configuration at the path you specify. Example: rails new ~/Code/Ruby/weblog This generates a skeletal Rails installation in ~/Code/Ruby/weblog. See the README in the newly created application to get going.

    Read the article

  • Testing a patch to the Rails mysql adapter

    - by Sleepycat
    I wrote a little monkeypatch to the Rails MySQLAdapter and want to package it up to use it in my other projects. I am trying to write some tests for it but I am still new to testing and I am not sure how to test this. Can someone help get me started? Here is the code I want to test: unless RAILS_ENV == 'production' module ActiveRecord module ConnectionAdapters class MysqlAdapter < AbstractAdapter def select_with_explain(sql, name = nil) explanation = execute_with_disable_logging('EXPLAIN ' + sql) e = explanation.all_hashes.first exp = e.collect{|k,v| " | #{k}: #{v} "}.join log(exp, 'Explain') select_without_explain(sql, name) end def execute_with_disable_logging(sql, name = nil) #:nodoc: #Run a query without logging @connection.query(sql) rescue ActiveRecord::StatementInvalid => exception if exception.message.split(":").first =~ /Packets out of order/ raise ActiveRecord::StatementInvalid, "'Packets out of order' error was received from the database. Please update your mysql bindings (gem install mysql) and read http://dev.mysql.com/doc/mysql/en/password-hashing.html for more information. If you're on Windows, use the Instant Rails installer to get the updated mysql bindings." else raise end end alias_method_chain :select, :explain end end end end Thanks.

    Read the article

  • Creating an Admin directory in Rails

    - by matsko
    I've been developing the CMS backend for a website for a few weeks now. The idea is to craft everything in the backend first so that it can manage the database and information that will be displayed on the main website. As of now, I currently have all my code setup in the normal rails MVC structure. So the users admin is /users and videos is /videos. My plans are to take the code for this and move it to a /admin directory. So the two controllers above would need to be accessed by /admin/users and /admin/videos. I'm not sure how todo the ruote (adding the /admin as a prefix) nor am I sure about how to manage the logic. What I'm thinking of doing is setting up an additional 'middle' controller that somehow gets nested between the ApplicationControler and the targetted controller when the /admin directory is accessed. This way, any additional flags and overloaded methods can be spawned for the /admin section only (I believe I could use a filter too for this). If that were to work, then the next issue would be separating the views logic (but that would just be renaming folders and so on). Either I do it that way or I have two rails instances that share the MVC code between them (and I guess the database too), but I fear that would cause lots of duplication errors. Any ideas as to how I should go about doing this? Many thanks!

    Read the article

  • How can I make my Ruby on Rails 2.3.4 application "Rails 3-ready"

    - by marcgg
    I'm developing an application with Ruby on Rails that I want to maintain for at least a few years, so I'm concerned about the next version coming up soon. Going from Rails 1 to Rails 2 was such a big pain that I didn't bother and froze my gems and let the application die, alone, in the dark. On this project I don't want to do that. First because this new version looks awesome, but also because this application may turn into a real product. How can I prepare my application so that it will be upgradable with as little changes as possible. How time consuming do you think switching version will be? And what about my server? Deployment? I'm already looking at deprecation notices... what else can I do?

    Read the article

  • Rails - handling global site settings

    - by egarcia
    I'm developing a new rails application which is supposed to be installed several times in order to implement several sites. There are some things, like the "Site Title" or the "Default Number of Items per Page" that clearly belong to a "global settings" table / config file. I've made a list of the things I think I'll need: ActiveRecord model that is capable of: Storing different kinds of data. I suppose this would be accomplished encoding the values on a string on the db, probably with a "type" field. Indexing settings by name Validations based on a "type" attribute (i.e. don't accept invalid dates on "date" settings) Validations based on a allows_nil property. A controller that allows me to change settings via views. I'm pretty sure I could implement this myself, but I'm not willing to reinvent the wheel. I've done some searching, but I could only find rails-settings, which doesn't really serve me: I need a proper model & controller so I can use declarative-authorization, and it does not provide any controller or view facilities. Is there a gem or plugin out there that implements what I want, or any library I should look at? Thanks a lot.

    Read the article

  • Cannot translate date formats from rails form to mysql db

    - by Steve
    I have a simple search form in rails 3 that has two date fields. I'm having a problem getting these dates into my mysql db. I've tried using the american_date gem, specifying date formats in my initializers, in the config/locales/en.yml file, and directly on the date on the date fields themselves. Currently, I'm setting the rails-approved date format in the view - <%= f.text_field :depart_date, :value=> Date.today.strftime('%Y-%m-%d') %> The dateformat in my DB is also YYYY-mm-dd, so things should be going smoothly. The console tells me that the two date fields are both class = "Date" I think I've found the disconnect. From the logs - Started POST "/searches" for 127.0.0.1 at 2013-10-30 17:43:26 -0400 Processing by SearchesController#create as HTML Parameters: {"utf8"=>"v","search"=>{"depart_date"=>"2013-10-30", "return_date"=>"2013-11-09"} ?[1m?[35m (0.0ms)?[0m BEGIN ?[1m?[36mSQL (0.0ms)?[0m ?[1mINSERT INTO `searches` (`depart_date`,`return_date`) VALUES ('2013-30-10','2013-09-11')?[0m ?[1m?[35m (2.0ms)?[0m COMMIT Note that the month and day values are switched in the insert statement. How can I prevent this from happenening?

    Read the article

  • Open Source Security packages for Rails

    - by Edwin
    I'm currently creating a complete web application using Rails 3 to familiarize myself with its inner workings and to gain a better appreciation of a working web application's moving parts. (Plus, since I'm still working on my degree, I hope that it will give me a better idea of what's BS in my education requirements and which weaknesses/skills I should focus on.) The example application I'm working on is an ecommerce site, and I've already configured the backend, routes, controllers, and so on. As part of the application, I'd like to integrate a second layer of security on top of the one Rails already provides for user authentication. However, I've been unable to find any on Google, with the exception of OAuth - which, from my understanding, is meant to secure API calls. While I could roll my own secure authentication system, I'm only in my second year of college and recognize that A) I know little about security, and B) there are developers that know much more about security that are working on open-source projects. What are some actively developed open-source security packages or frameworks that can be easily added to Rails? Pros and cons are not necessary, as I can do the research myself. P.S. I'm not sure whether I posted this in the right SE site; please migrate to SO or Security if it is more appropriate there.

    Read the article

  • git push >> fatal: no configured push destination

    - by Marc
    I'm still going through some guides on RoR and i'm stuck here at "Deploying the demo app" I followed instructions: " With the completion of microposts resources, now is a good time to push the repository up to GitHub: " $ git add . $ git commit -a -m "Finish demo app" $ git push What happened wrong here was the push part.. it outputted this: $ git push fatal: No configured push destination. Either specify the URL from the command-line or configure a remote repository using git remote add < name < url git push < name So i tried following the insturctions by doing this command: $git remote add demo_app 'www.github.com/levelone/demo_app' fatal: remote demo_app already exists. So i push: $git push demo_app fatal: 'www.github.com/levelone/demo_app' does not appear to be a git repository fatal: The remote end hung up unexpectedly What can i do here? Any help would be much appreciated. -Marc

    Read the article

  • String length difference between ruby 1.8 and 1.9

    - by Raghu
    I have a website thats running on ruby 1.8.7 . I have a validation on an incoming post that checks to make sure that we allow upto max of 12000 characters. The spaces are counted as characters and tab and carriage returns are stripped off before the post is subjected to the validation. Here is the post that is subjected to validation http://pastie.org/5047582 In ruby 1.9 the string length shows up as 11909 which is correct. But when I check the length on ruby 1.8.7 is turns out to be 12044. I used codepad.org to run this ruby code which gives me http://codepad.org/OxgSuKGZ ( which outputs the length as 12044 which is wrong) but when i run this same code in the console at codeacademy.org the string length is 11909. Can anybody explain me why this is happening ??? Thanks

    Read the article

  • RoR | how to get content_tags to nest?

    - by Digital Cake
    As you can see I have a helper with a method that I'm trying to render out to the view. The nested content_tags do not render what is my disconnect about this tag? def draw_calendar(selected_month, month, current_date) content_tag(:table) do content_tag(:thead) do content_tag(:tr) do I18n.t(:"date.abbr_day_names").map{ |day| content_tag(:th, day, :escape => false) } end #content_tag :tr end #content_tag :thead content_tag(:tbody) do month.collect do |week| content_tag(:tr, :class => "week") do week.collect do |date| content_tag(:td, :class => "day") do content_tag(:div, date.day, :class => (Date.today == current_date ? "today" : nil)) end #content_tag :td end #week.collect end #content_tag :tr end #month.collect end #content_tag :tbody end #content_tag :table end #draw_calendar

    Read the article

  • Have error message show when form is created through AJAX

    - by Railslearner
    I have a page called /add that you can add a Dog on and the form is in its own partial. I'm using Simple Form and Twitter Bootstrap. I added the files for the main Bootstrap but use a gem for simple_form to work with it just so you know. DogsController # new.js.erb (deleted new.html.erb) def new @dog = Dog.new respond_to do |format| format.js end end # create.js.erb def create @dog = current_user.dogs.new(params[:dog]) respond_to do |format| if @dog.save format.html { redirect_to add_url, notice: 'Dog was successfully added.' } format.json { render json: @dog, status: :created, location: @dog} format.js else format.html { render 'pages/add' } format.json { render json: @dog.errors, status: :unprocessable_entity } end end end dogs/_form.html.erb <%= simple_form_for(@dog, :remote => true) do |f| %> <%= render :partial => "shared/error_message", :locals => { :f => f } %> <%= f.input :name %> <%= f.button :submit, 'Done' %> <% end %> This line: <%= render :partial => "shared/error_message", :locals => { :f => f } %> Is for bootstrap so it renders the errors html correctly. PagesController def add respond_to do |format| format.html end end pages/add.html.erb <div id="generate-form"> </div> dogs/new.js.erb $("#generate-form").html("<%= escape_javascript(render(:partial => 'dogs/form', locals: { dog: @dog })) %>"); Now how would I get this to render the error partial as if it was still on my dogs/new.html.erb since its being created through AJAX? I don't need client side validations do I?

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >