Search Results

Search found 297 results on 12 pages for 'rails3'.

Page 9/12 | < Previous Page | 5 6 7 8 9 10 11 12  | Next Page >

  • I have the CSS & JS, how do I convert that to erb for my Rails app?

    - by marcamillion
    So I have the foundation of my Rails app, then I went ahead and did the JS and CSS. How do I then take the CSS and JS that I have, and apply it to the app in a 'Rails Way'. i.e. a dynamic way that works nicely. Can you give me some tutorials/articles/resources that I can read up to guide me, please? I have tried the Rails guides, but I find them a bit lacking. Any other good suggestions or tips that might help get me on the right track? Thanks.

    Read the article

  • Rendering another Action without changing URL?

    - by Michael Stum
    I have this code in my Rails 3 controller: def index now = Time.now.utc.strftime("%m%d") redirect_to :action => "show", :id => now end def show begin @date = Time.parse("12#{params[:id]}") dbdate = params[:id] rescue ArgumentError @date = Time.now.utc dbdate = @date.strftime("%m%d") end @date = @date.strftime("%B %d") @events = Event.events_for_date(dbdate) end So basically index is just a specialized version of show, hence I want it to execute show, render the show.html.erb view - but I do not want to change the URL like redirect_to does. I have tried this approach: def index now = Time.now.utc.strftime("%m%d") params[:id] = now show render :action => "show" end Now, this works, but it just smells badly. I'm new to Ruby and Rails, so I just wonder if there is something fundamentally wrong or if there is a better way to do this?

    Read the article

  • Using the MongoDB Ruby driver in Rails? (without an object mapper)

    - by Mark L
    I have recently been getting my feet wet in MongoDB using Mongoid w/ Rails 3, but I'm now interested in learning the low level MongoDB features using only the Ruby driver, and trying some map/reduce that would not be possible through Mongoid (afaik) I'm not entirely sure where in Rails I should be setting up the db connections etc, and any pointers would be much appreciated!

    Read the article

  • Rails - JSON object with an array?

    - by AnApprentice
    Hello, I'm able to create and send a JSON object like so: @mylist << { :id => item.id, :name => name.id } render :json => { :result => 'success', :mylist => @mylist } That works great. Problem I'm having now is that I need to include users with are 1 or more per item. @mylist << { :id => item.id, :name => name.id, :users => item.users } Where item.users contains a list of (user.id, user.name, user.desc). how do I include an array like users inside a json object? How to build in Rails and then how to parse it with jQuery? Thanks

    Read the article

  • Is DOM not being loaded ?

    - by Daniel
    I went through episode 88 (Dynamic menus) of the railscasts and when I try to load my *js.erb file in the browser shows me that my fetched data from the controller is getting there Controller def dynamic_departments @departments = Department.all end localhost:3000/javascripts/dynamic_departments.js var departments = new Array(); departments.push(new Array(1,'????',1)); departments.push(new Array(2,'???-???',2)); function facultySelected(){ faculty_id = $('falculty_id').getValue(); options = $('department_id').options; options.length = 1; departments.each(function(department){ if(department[0] == faculty_id){ options[options.length] = new Option(department[1],department[2]) } }); if(options.length == 1){ $('department_field').hide(); } else { $('department_field').show(); } } document.observe('dom:loaded', function(){ alert("DOM loaded"); //$('department_field').hide(); //$('faculty_id').observe('change',facultySelected); }); My routes.rb has the match ':controller/:action.:format' Still...after the page's loaded and I change the value of my collection_select or select nothing happens.What am I missing? *I called the 'alert' and commented the rest to test it....still nothing.

    Read the article

  • Rails 3 full-text search options (gems, plugins, etc)

    - by shiftshane
    I was wondering if there were any suggestions for how to best roll with full text searching in your Rails 3 apps? Thinking Sphinx and acts_as_ferret aren't updated for Rails 3 yet, and even basic activerecord search helpers like Searchlogic also aren't there yet. Any thoughts? Are you using any forked versions of the above gems that have been updated to Rails 3?

    Read the article

  • Testing form submission with Cucumber

    - by picardo
    I wrote a simple Cuke feature for a form on a demo site. The feature looks like this. Given I am on the home page When I set the "Start Date" to "2010-10-25" And I set the "End Date" to "2011-1-3" And I press the "Go" button Then I should see "Cake Shop" The idea is that after I press the Go button, a new page will load, showing a list of results, and one of the results should be "Cake Shop." But I have not managed to get this to work. Is there something that I am missing? Edit: here is the step definitions. Given /^I am on the "([^"]*)" page$/ do |page| visit root_path end When /^I set the "([^"]*)" to "([^"]*)"$/ do |field, date| fill_in field, :with=>date end When /^I press the "([^"]*)" button$/ do |arg1| click_button('Go') end The final step is defined in web_steps.rb I believe....and it's always there that it's failing. Then I should see "Cake Shop" # features/step_definitions/web_steps.rb:107 expected #has_content?("Cake Shop") to return true, got false (RSpec::Expectations::ExpectationNotMetError) ./features/step_definitions/web_steps.rb:110:in block (2 levels) in <top (required)>' ./features/step_definitions/web_steps.rb:14:in with_scope' ./features/step_definitions/web_steps.rb:108:in /^(?:|I )should see "([^"]*)"(?: within "([^"]*)")?$/' features/specify_timerange.feature:12:in Then I should see "Cake Shop"'

    Read the article

  • Uninstall Rails 3 with dependencies?

    - by Trevor Burnham
    I like that Rails 3 is so easy to install: gem install rails --pre, and all of the dependencies are automatically installed for you. But, what about uninstalling it? If I just do gem uninstall rails, I still have actionmailer (3.0.0.beta3) actionpack (3.0.0.beta3) activemodel (3.0.0.beta3) activerecord (3.0.0.beta3) activeresource (3.0.0.beta3) activesupport (3.0.0.beta3) which I want to get rid of. What's the easiest way to do so?

    Read the article

  • Rails 3 routes and using GET to create clean URLs?

    - by Hard-Boiled Wonderland
    I am a little confused with the routes in Rails 3 as I am just starting to learn the language. I have a form generated here: <%= form_tag towns_path, :method => "get" do %> <%= label_tag :name, "Search for:" %> <%= text_field_tag :name, params[:name] %> <%= submit_tag "Search" %> <% end %> Then in my routes: get "towns/autocomplete_town_name" get "home/autocomplete_town_name" match 'towns' => 'towns#index' match 'towns/:name' => 'towns#index' resources :towns, :module => "town" resources :businesses, :module => "business" root :to => "home#index" So why when submitting the form do I get the URL: /towns?utf8=?&name=townname&commit=Search So the question is how do I make that url into a clean url like: /towns/townname Thanks, Andrew

    Read the article

  • Linking two models in a multi-model form

    - by Elliot
    Hey Guys, I have a nested multimodel form right now, using Users and Profiles. Users has_one profile, and Profile belongs_to Users. When the form is submitted, a new user is created, and a new profile is created, but they are not linked (this is the first obvious issue). The user's model has a profile_id row, and the profile's model has a user_id row. Here is the code for the form: <%= form_for(@user, :url => teams_path) do |f| %> <p><%= f.label :email %><br /> <%= f.text_field :email %></p> <p><%= f.label :password %><br /> <%= f.password_field :password %></p> <p><%= f.label :password_confirmation %><br /> <%= f.password_field :password_confirmation %></p> <%= f.hidden_field :role_id, :value => @role.id %></p> <%= f.hidden_field :company_id, :value => current_user.company_id %></p> <%= fields_for @user.profile do |profile_fields| %> <div class="field"> <%= profile_fields.label :first_name %><br /> <%= profile_fields.text_field :first_name %> </div> <div class="field"> <%= profile_fields.label :last_name %><br /> <%= profile_fields.text_field :last_name %> </div> <% end %> <p><%= f.submit "Sign up" %></p> <% end %> A second issue, is even though the username, and password are successfully created through the form for the user model, the hidden fields (role_id & company_id - which are also links to other models) are not created (even though they are part of the model) - the values are successfully shown in the HTML for those fields however. Any help would be great!

    Read the article

  • How do I update a cumulative field in a Rails database (using ActiveRecord or Mongoid)?

    - by picardo
    I want to update a field in a database table that has to have a cumulative value. So basically I need to find the current value of the field and update it using a new number. My first inefficient try at this (in Mongoid) is: v = Landlord.where(:name=>"Lorem") v.update_attributes(:violations=>v.violations + 10) Is there a simple method than making one query to read, then sum up, and another query to write?

    Read the article

  • With Rails 3 routes, how do you only allow a requests from 127.0.0.1?

    - by micah
    I'm writing an app where several of the routes should only be accessible from localhost. It looks like this is possible with the new routing system. http://www.railsdispatch.com/posts/rails-3-makes-life-better This has examples of restricting routes based on IP address, and setting up an IP address blacklist for your routes, but I'm interested in a whitelist with just one IP address. It would be cool if something like this worked: get "/posts" => "posts#show", :constraints => {:ip => '127.0.0.1'} But it didn't. Am I just missing the right syntax?

    Read the article

  • Rails - Posting a Boolean (true or False) and updating the DB in the controller

    - by AnApprentice
    Hello, in my Rails 3 App, I'm posting with jQuery the following: http://0.0.0.0:3000/topics/read_updater?&topic_id=101&read=true In my controller: def read_updater current_user.topics.where(:topic_id => params[:topic_id]).update_all(:read => params[:read]) render :json => {:status => 'success' } end params[:conversation_id] works great, but params[:read] is inserting empty values in the DB, even though jQuery is posting either a true or false. Ideas? I want rails to update the DB with either true or false. Thanks

    Read the article

  • How do I correctly install ambethia/recaptcha with rails 3

    - by TLK
    I have done the following steps: Added to gemfile: gem "recaptcha" Added to config/initializers/recaptcha.rb Recaptcha.configure do |config| config.public_key = 'MyKeyHere' config.private_key = 'MyKeyHere' end Added to view: = raw recaptcha_tags Ran: bundle install ...then restarted server. The result? undefined local variable or method `recaptcha_tags' for #<#<Class:0x1053baaa0>:0x1053b69c8>

    Read the article

  • Ruby on Rails: How to create associated models on the fly ?

    - by Misha Moroshko
    I have the following models: class Product < ActiveRecord::Base belongs_to :brand belongs_to :model accepts_nested_attributes_for :brand, :model ... end class Brand < ActiveRecord::Base has_many :products has_many :models ... end class Model < ActiveRecord::Base has_many :products belongs_to :brand accepts_nested_attributes_for :brand ... end I have a problem to create a new product. Here is the relevant code in the controller: class ProductsController < ApplicationController ... def create @product = Product.new(params[:product]) if @product.save ... # Here is the error end ... end When user adds a new brand and a new model, params[:product] contains the following: "brand_attributes"=>{"name"=>"my_new_brand"} "model_attributes"=>{"model_no"=>"my_new_model"} and I got the following error: Mysql2::Error: Column 'brand_id' cannot be null: INSERT INTO `models` ... because model has a foreign key brand_id which is not set. I can't set it because the brand (like the model) is created on the fly when the product is created. I don't want to create the brand before the product, because then I the product has errors, I will need to delete the created brand. Then I tried to change params[:product] like this: "brand_attributes"=>{"name"=>"my_new_brand", "model_attributes"=>{"model_no"=>"my_new_model"}} but I end up with this: unknown attribute: model_attributes What would be the proper way to handle this ?

    Read the article

  • Embed Git Commit Log in Rails App?

    - by Andrew
    So, I have a 'development blog' in a rails app I'm working on right now. I'm using Git for version control and deployment (although right now I'm the only person working on it). Now, when I make changes in Git I put a pretty decent log entry about what I've done. I'd love to have the Git commit log automatically posted to the development blog -- or otherwise available for others to read within the deployed site. Is there an automated way to pull the Git Commit Log into a view in a rails app?

    Read the article

  • Paperclip: Stay put on edit

    - by EricR
    When a user edits something in my application, they're forced to re-upload their image via paperclip even if they aren't changing it. Failing to do so will cause an error, since I validate_presence_of :image. This is quite annoying. How can I make it so Paperclip won't update its attributes if a user simply doesn't supply a new image on an edit? The photo controller is fresh out of Rails' scaffold generator. The rest of the source code is provided below. models/accommodation.rb class Accommodation < ActiveRecord::Base attr_accessible :photo validates_presence_of :photo has_one :photo has_many :notifications belongs_to :user accepts_nested_attributes_for :photo, :allow_destroy => true end controllers/accommodation_controller.rb class AccommodationsController < ApplicationController def index @accommodations = Accommodation.all end def show @accommodation = Accommodation.find(params[:id]) rescue ActiveRecord::RecordNotFound flash[:error] = "Accommodation not found." redirect_to :home end def new @accommodation = current_user.accommodations.build @accommodation.build_photo end def create @accommodation = current_user.accommodations.build(params[:accommodation]) if @accommodation.save flash[:notice] = "Successfully created your accommodation." redirect_to @accommodation else @accommodation.build_photo render :new end end def edit @accommodation = Accommodation.find(params[:id]) @accommodation.build_photo rescue ActiveRecord::RecordNotFound flash[:error] = "Accommodation not found." redirect_to :home end def update @accommodation = Accommodation.find(params[:id]) if @accommodation.update_attributes(params[:accommodation]) flash[:notice] = "Successfully updated accommodation." redirect_to @accommodation else @accommodation.build_photo render :edit end end def destroy @accommodation = Accommodation.find(params[:id]) @accommodation.destroy flash[:notice] = "Successfully destroyed accommodation." redirect_to :inkeep end end models/photo.rb class Photo < ActiveRecord::Base attr_accessible :image, :primary belongs_to :accommodation has_attached_file :image, :styles => { :thumb=> "100x100#", :small => "150x150>" } end

    Read the article

  • How do you crop a specific area with paperclip in Rails (3)?

    - by Smickie
    Hi, I have paperclip in Rails (3) working with simple cropping, for example the blow code makes a simple crop of the thumbnail: has_attached_file :image, :styles => { :thumb => "90x90#" }, :default_style => :thumb However I was wondering how do you crop a very specific area of an image; lets say you have an x and y coordinate to start from and then a width and height of the crop. How do you go about passing a complex style like this in? Thanks very much.

    Read the article

  • Rails 3 respond_to: default format?

    - by bdorry
    I am converting a Rails 2 application to Rails 3. I currently have a controller set up like the following: class Api::RegionsController < ApplicationController respond_to :xml, :json end with and an action that looks like the following: def index @regions = Region.all respond_with @regions end The implementation is pretty straightforward, api/regions, api/regions.xml and api/regions.json all respond as you would expect. The problem is that I want api/regions by default to respond via XML. I have consumers that expect an XML response and I would hate to have them change all their URLs to include .xml unless absolutely necessary. In Rails 2 you would accomplish that by doing this: respond_to do |format| format.xml { render :xml => @region.to_xml } format.json { render :json => @region.to_json } end But in Rails 3 I cannot find a way to default it to an XML response. Any ideas?

    Read the article

  • Rails: translate ActiveRecord error template headers for a single model

    - by Chris
    Hi, I'm trying to rename the authlogic error messages in a Rails 3 app. The general format I found out working in Rails 3: de: errors: template: header: one: "Konnte {{model}} nicht speichern: ein Fehler." other: "Konnte {{model}} nicht speichern: {{count}} Fehler." body: "Bitte überprüfen Sie die folgenden Felder: But I want to change this for the authlogic user session model (and only for this one) because when the Login fails, the message "Could not save user session" does not make very much sense. How can I do that?

    Read the article

  • Is there an ActiveRecord equivalent to using a nested subquery i.e. ... where NOT IN(select...) ?

    - by Snorkpete
    I have 3 models: Category, Account, and SubAccount The relations are: Accounts has_many :sub_accounts Categories has_many :sub_accounts I wanted to get a list of all Categories that are not used by a given account. My method in the Category model currently looks like: class Category < ActiveRecord::Base def self.not_used_by(account) Category.find_by_sql("select * from categories where id not in(select category_id from sub_accounts where account_id = #{account.id})") end end My question is, is there a cleaner alternative than using SQL? NB. I am currently using Rails 3(beta)

    Read the article

  • How Does Rails 3's "data-method='delete'" Degrade Gracefully?

    - by viatropos
    Rails 3 does some cool stuff to make Javascript unobtrusive, so they've done things like this: = link_to "Logout", user_session_path, :method => :delete ..converts to <a href="/logout" data-method="delete" rel="nofollow">Logout</a> But it just occurred to me.. When I turn off javascript the method isn't DELETE anymore, it's GET as expected. So are there plans to, or is there some way to, allow these data- attributes to degrade gracefully, so that link still is a DELETE request?

    Read the article

  • Rails 3 Initializers: No such file to load

    - by waveslider
    I am trying to use the Sunlight API gem with a Rails project. I have installed the gem and can successfully use it from irb. However, when I put the require statement (require 'sunlight') in sunlight.rb in config/initializers, I get the following error: /opt/local/lib/ruby/gems/1.8/gems/activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:209:in `require': no such file to load -- sunlight (LoadError) I checked the permissions on the gems directory, and it is world readable/executable. Here is the code from sunlight.rb: require 'rubygems' require 'sunlight' Sunlight::Base.api_key = 'bb7b775755054c54aa9715d202f6785c'

    Read the article

< Previous Page | 5 6 7 8 9 10 11 12  | Next Page >