Search Results

Search found 13929 results on 558 pages for 'ruby on rails plugins'.

Page 47/558 | < Previous Page | 43 44 45 46 47 48 49 50 51 52 53 54  | Next Page >

  • modify the name of the :id to :another_id in rails 3

    - by figuedmundo
    Well I googled my question but I couldn't find anything or I it's not the correct question.. The issue is I need modify the primary_key name of the database :id with :another_id, in my project I need to use pgrouting and it contains several plsql functions and these functions uses the primary-key with the name gid and instead of modify the plsql functions is better change the id name, and I was thinking do this with a migration becouse I thought it's the rails way. Is it possible, and how I can do this ?? Thanks in advance and sorry for my english.

    Read the article

  • Building Admin Areas in Rails - General Questions

    - by Carb
    What is the typical format/structure for creating an administrative area in a Rails application? Specifically I am stumped in the vicinity of these topics: How do you deal with situations where a model's resources are available to both the public and the Admin? i.e. A User model where anyone can create users, login, etc but only the admin can view users, delete/update them, etc. What is the proper convention for routing? How does one structure controllers? Are duplicate controllers considered OK? i.e. An admin version and the non-admin version? Thank you!

    Read the article

  • Rails Model has_many with multiple foreign_keys

    - by Kenzie
    Relatively new to rails and trying to model a very simple family "tree" with a single Person model that has a name, gender, father_id and mother_id (2 parents). Below is basically what I want to do, but obviously I can't repeat the :children in a has_many (the first gets overwritten). class Person < ActiveRecord::Base belongs_to :father, :class_name => 'Person' belongs_to :mother, :class_name => 'Person' has_many :children, :class_name => 'Person', :foreign_key => 'mother_id' has_many :children, :class_name => 'Person', :foreign_key => 'father_id' end Is there a simple way to use has_many with 2 foreign keys, or maybe change the foreign key based on the object's gender? Or is there another/better way altogether? Thanks!

    Read the article

  • Custom Rails Validation (Doesn't seem to be working)

    - by Karl Entwistle
    Hey guys ive got the following Model for Accounts require 'net/http' require 'uri' require 'date' class Account < ActiveRecord::Base validates_presence_of :username, :password, :on => :update validate :valid_expiry_date, :on => :update def valid_expiry_date reply = Net::HTTP.get URI.parse("http://api.rapidshare.com/cgi-bin/rsapi.cgi?sub=getaccountdetails_v1&type=prem&login=" + username + "&password=" + password) account = Time.at(reply[80..90].to_i) if (Time.now + 2419200) <= account return true else return false errors.add_to_base("Sorry this account isnt valid") end end end I know the code works in a ruby.rb file and will return true or false, however I seem to be having rather a lot of difficultly trying to translate this code into an actual validation, any help would be much appreciated. Thanks :) Its also defiantly at least connecting to the website as my firewall asked me if the Terminal was aloud to access it. At the moment not only is it displaying no errors its actually letting anything through and saving it.

    Read the article

  • Rails - inheritance hierarchy of classes where an subtipe can play two roles

    - by Miquel
    I need to model Owners and Rentees in an application, so you have stuff that is always owned by someone and can be rented for someone else. I first approached this problem with Single Table Inheritance because both types of person will share all attributes, so you would have a model called Person associated to a table people with Owner and Rentee inheriting from Person. The problem is that Single type inheritance discerns subtypes using a field type and therefore a record in the table can represent either an Owner or a Rentee but not both at the same time, while in the real context you can have an Owner which is renting something from another Owner and therefore that person is at the same time an Owner and a Rentee. How would you approach this problem? Would you use separated tables fro owners and rentees? Is there any other type of table inheritance in Rails?

    Read the article

  • Rails routing: how to mix "GET" and "PUT"

    - by thermans
    Not sure how to frame this question (I'm still wrapping my head around Rails). Let's try this: Say I wanted to implement the user side of Ryan Bates' excellent railscast on nested models. (He shows how to implement a survey where you can add and remove questions and answers dynamically). I want the user's side of this: to be able to answer questions and, not in the tutorial, be able to add comments. It seems to me that you have to implement a view that shows the questions and answers, allow selection of the answers, and the input of comments. So there would need to be a way to show the information, but also update the model on input, right? I know I'm not explaining this very well. I hope you understand what I'm getting at. Is it just a question of setting up the right routes? Or is there some controller mojo that needs to happen?

    Read the article

  • Rails Variable across all controller actions

    - by bob
    Hello, This should be a very simple rails question. I have a variable like the following. @administration = Administration.first I want this variable to be accessible through every controller action across all my controllers so for example if I have a Product controller and inside of it I have the usual CRUD actions, I want the @administration variable as defined above to be put into all the CRUD actions. (It would not be needed in destroy or create or update). I have many controllers throughout my project and I was wondering if there is an easier way than adding it manually through all of the actions that I want it in. I tried a global variable $administration = Administration.first but I run into an issue where it is not updated when I update the actual content of the Administration.first table. Also, I would like to avoid global variables. Any help would be much appreciated. Thanks! :)

    Read the article

  • Rails 3 Create method using nested resources?

    - by user1461119
    How can I clean this up using rails 3 features? I have a post that belongs to a group and also a user. The group and user has_many posts. I am using a nested resource resources :groups do resources :posts end <%= form_for @post, :url => group_posts_path(params[:group_id]) do |f| %> .... <% end %> def create @group = Group.find(1) @post = @group.posts.build(params[:post]) @post.user_id = current_user.id respond_to do |format| if @post.save ..... end end end Thank you.

    Read the article

  • Rails before_filter on subclasses beeing called twice

    - by rubenfonseca
    Hi! I'm at Rails 2.3.5 and I have this problem: class BaseController < ApplicationController before_filter :foo, :only => [:index] end class ChildController < BaseController before_filter :foo, :only => [:index, :show, :other, :actions] end The problem is that on ChildController, the :foo before filter gets called twice. I've tried a number of workarounds around this problem. If I don't include the :index action on the child, it never gets called for that action. The solution I found works, but is very very ugly skip_before_filter :foo before_filter :foo, :only => [:index, :show, :other, :actions] Is there a better way to solve this problem? Thanks

    Read the article

  • NoMethodError when trying to invoke helper method from Rails controller

    - by John Topley
    I'm getting a NoMethodError when trying to access a method defined in one of my helper modules from one of my controller classes. My Rails application uses the helper class method with the :all symbol as shown below: class ApplicationController < ActionController::Base helper :all . . end My understanding is that this should make all of my controller classes automatically include all of the helper modules within the app/helpers directory, therefore mixing in all of the methods into the controllers. Is this correct? If I explicitly include the helper module within the controller then everything works correctly.

    Read the article

  • Rails create_table query

    - by Steve
    Hi, I am a beginner in Rails. In the following code,there is an id which is set as false. What's the meaning of it? class CreateCoursesStudents < ActiveRecord::Migration def self.up create_table :courses_students, :id => false do |t| t.integer :course_id, :null => false t.integer :student_id, :null => false end # Add index to speed up looking up the connection, and ensure # we only enrol a student into each course once add_index :courses_students, [:course_id, :student_id], :unique => true end def self.down remove_index :courses_students, :column => [:course_id, :student_id] drop_table :courses_students end end Thanks

    Read the article

  • Rails model to represent multiple fields

    - by Tristan O'Neil
    I'm developing a rails project where I have one data model with multiple fields that are collection selects. I'd like to create another model to represent all of these collection select fields. So, for instance, my main data model has three collection select fields -- one for county, one for category, and one for classification. I could separate these into three separate data models, but that seems redundant since they all share the same characteristics. They have a type and a value, like a county is a county and it has a value of let's say Sonoma, just as category has a type of category and a value of let's say Winery. If you've ever used Drupal, I'm basically looking for the behavior of the taxonomy functionality. So you see my dilemma: I need to separate these fields into three separate fields but they have very similar data structures. Any suggestions would be greatly appreciated.

    Read the article

  • Rails 3 date_select for year only

    - by tvalent2
    I have a form in my Rails 3 app where I want to create a select tag for just the year on a method :grad_year. I have everything working - and storing - properly using date_select and adding :discard_month and :discard_day. However when I render @profile.grad_year I get the month and day values. So I'm wondering how to store and render only the year for @profile.grad_year? Here is the form: <%= f.date_select :grad_year, {:start_year => Time.now.year, :end_year => Time.now.year - 95, :discard_day => true, :discard_month => true}, :selected => @profile.grad_year %> In my migration: t.date :grad_year

    Read the article

  • Rails: Link changes one attribute and then goes back

    - by James
    Rails newbie here. I have a list of items which can have a status represented by an integer (right now its just 1=active 0=inactive). What I want is next to each item a link to change the status of that item. So it might look like this: A nice item - Enable Another pretty item - Disable I can't think of how to make the link work. I just want a user to click the link and then the page refreshes and the item get updated. This doesn't work: <%= link_to "Enable", :controller => "items", :action => "update", :status => 1 %>

    Read the article

  • Rails validation issue with before_validation

    - by Chance
    I'm still fairly new to rails so I'm not sure what I'm missing here. I'm using GeoKit to geocode an address upon saving. I have a method that geocodes an address and if it fails to find it, it adds an error to the errors list. I've tested it in the console and it is failing on the geocode (presumably adding the error) but still saving successfully. acts_as_mappable before_validation_on_create :geocode_address before_validation_on_update :geocode_address validates_presence_of :street validates_presence_of :city validates_presence_of :state validates_presence_of :zip validates_presence_of :name validates_uniqueness_of :name def geocode_address geo=Geokit::Geocoders::MultiGeocoder.geocode ("#{street}, #{city}, #{state}, #{zip}") puts "geocoded: #{street}, #{city}, #{state}, #{zip}" if geo.success self.lat, self.lng = geo.lat,geo.lng else errors.add(:street, "Could not Geocode address") end puts "geo status: #{geo.success}" end Any help would be greatly appreciated, thanks :)

    Read the article

  • Rails - inheritance hierarchy of classes where a subtype can play two roles

    - by Miquel
    I need to model Owners and Rentees in an application, so you have stuff that is always owned by someone and can be rented for someone else. I first approached this problem with Single Table Inheritance because both types of person will share all attributes, so you would have a model called Person associated to a table people with Owner and Rentee inheriting from Person. The problem is that Single type inheritance discerns subtypes using a field type and therefore a record in the table can represent either an Owner or a Rentee but not both at the same time, while in the real context you can have an Owner which is renting something from another Owner and therefore that person is at the same time an Owner and a Rentee. How would you approach this problem? Would you use separated tables for owners and rentees? Is there any other type of table inheritance in Rails?

    Read the article

  • Fork a process and send data to it inside Rails

    - by taro
    I'm making a Rails application. In the one action I need to spawn a long running process. This is not a problem. I can fork new process using spawn gem or some other. But some time after process has been spawned, user must be able to pass additional data to that process. Sure, I can fork process which will listen a UNIX socket, store socket address in the HTTP session and communicate with that process using drb protocol when user will require to pass new data to process. But I think it is not best solution and it will be a problem to deploy an application to the hosting. What is the easy way to do that?

    Read the article

  • Rails: Thread won't affect database unless joined to main Thread

    - by hatboysam
    I have a background operation I would like to occur every 20 seconds in Rails given that some condition is true. It kicked off when a certain controller route is hit, and it looks like this def startProcess argId = self.id t = Thread.new do while (Argument.isRunning(argId)) do Argument.update(argId) Argument.markVotes(argId) puts "Thread ran" sleep 20 end end end However, this code does absolutely nothing to my database unless I call "t.join" in which case my whole server is blocked for a long time (but it works). Why can't the read commit ActiveRecords without being joined to the main thread? The thread calls methods that look something like def sample model = Model.new() model.save() end but the models are not saved to the DB unless the thread is joined to the main thread. Why is this? I have been banging my head about this for hours.

    Read the article

  • Automatically Host User Domains in Rails/Apache

    - by Steve F
    Hi, I'm currently developing a user facing web application that gives each new user their own subdomain on the site, which is fine (using subdomain_fu), but is there a way to let a user map their own domain to this subdomain? I know how to do this manually through SSH-ing into the server and editing the Apache Vhosts file by hand, but is there a way to do this automatically so that a user simply enters their domain into a box on the site (obviously they'd have to change their own DNS elsewhere)? I'm using Ruby 1.8 and Rails 2.3.3 on top of Apache. Essentially letting; http://user.application.com/article-1 be accessed from http://userdomain.com/article-1 Thanks for any help!

    Read the article

  • Dev Environment Tests Not 100% Compatible with Staging/Production in Rails

    - by aronchick
    We use a bunch of specific apps/APIs that (unfortunately) differ quite a bit from dev to staging/production. We use tests and continuous integration at each stage, but in dev, the tests fail annoyingly (throwing dialogs, etc - thanks Windows for the 64-bit notification!). I hate to write custom code, but are there some best practices for how to allow a subset of testing in ruby/rails - or for patching out specific tests when you're running on Windows? Some specific situations that: Identify.exe does not support 64-bit Windows and throws a dialog. Sethostname is not supported, and throws an error (at least it's command line).

    Read the article

  • NRPE Warning threshold must be a positive integer

    - by Frida
    OS: Ubuntu 12.10 Server 64bits I've installed Icinga, with ido2db, pnp4nagios and icinga-web (last release, following the instruction given in the documentation, installation with apt, etc). I am using icinga-web to monitor my hosts. For the moment, I have just my localhost, and all is perfect. I am trying to add a host and monitor it with NRPE (version 2.12): root@server:/etc/icinga# /usr/lib/nagios/plugins/check_nrpe -H client NRPE v2.12 The configuration looks good. I've created a file in /etc/icinga/objects/client.cfg as below on the server: root@server:/etc/icinga/objects# cat client.cfg define host{ use generic-host ; Name of host template to use host_name client alias client.toto address xx.xx.xx.xx } # Service Definitions define service{ use generic-service host_name client service_description CPU Load check_command check_nrpe_1arg!check_load } define service{ use generic-service host_name client service_description Number of Users check_command check_nrpe_1arg!check_users } And add in my /etc/icinga/commands.cfg: # this command runs a program $ARG1$ with no arguments define command { command_name check_nrpe command_line /usr/lib/nagios/plugins/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ -a $ARG2$ } # this command runs a program $ARG1$ with no arguments define command { command_name check_nrpe_1arg command_line /usr/lib/nagios/plugins/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ } But it does not work. These are the logs from the client: Dec 3 19:45:12 client nrpe[604]: Connection from xx.xx.xx.xx port 32641 Dec 3 19:45:12 client nrpe[604]: Host address is in allowed_hosts Dec 3 19:45:12 client nrpe[604]: Handling the connection... Dec 3 19:45:12 client nrpe[604]: Host is asking for command 'check_users' to be run... Dec 3 19:45:12 client nrpe[604]: Running command: /usr/lib/nagios/plugins/check_users -w -c Dec 3 19:45:12 client nrpe[604]: Command completed with return code 3 and output: check_users: Warning t hreshold must be a positive integer#012Usage:check_users -w -c Dec 3 19:45:12 client nrpe[604]: Return Code: 3, Output: check_users: Warning threshold must be a positive integer#012Usage:check_users -w -c Dec 3 19:44:49 client nrpe[32582]: Connection from xx.xx.xx.xx port 32129 Dec 3 19:44:49 client nrpe[32582]: Host address is in allowed_hosts Dec 3 19:44:49 client nrpe[32582]: Handling the connection... Dec 3 19:44:49 client nrpe[32582]: Host is asking for command 'check_load' to be run... Dec 3 19:44:49 client nrpe[32582]: Running command: /usr/lib/nagios/plugins/check_load -w -c Dec 3 19:44:49 client nrpe[32582]: Command completed with return code 3 and output: Warning threshold mu st be float or float triplet!#012#012Usage:check_load [-r] -w WLOAD1,WLOAD5,WLOAD15 -c CLOAD1,CLOAD5,CLO AD15 Dec 3 19:44:49 client nrpe[32582]: Return Code: 3, Output: Warning threshold must be float or float trip let!#012#012Usage:check_load [-r] -w WLOAD1,WLOAD5,WLOAD15 -c CLOAD1,CLOAD5,CLOAD15 Dec 3 19:44:49 client nrpe[32582]: Connection from xx.xx.xx.xx closed. Have you any ideas?

    Read the article

  • testing devise with shoulda and machinist

    - by mattherick
    hello! I´d like to test my app with shoulda and machinist. I use the devise authentification gem. I get following error: $ ruby unit/page_test.rb c:/Ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/gem_dependency.rb:119:Warning: Gem::Dependency#version_requirements is deprecated and will be rem oved on or after August 2010. Use #requirement c:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:443:in load_missing_constant': uninitialized constant Admins (N ameError) from c:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:80:inconst_missing' from c:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:92:in const_missing' from c:/Users/Mattherick/Desktop/heimspiel/heimspiel_app/app/controllers/admins_controller.rb:1 from c:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:ingem_original_require' from c:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in require' from c:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:158:inrequire' from c:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:265:in require_or_load' from c:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:224:independ_on' ... 12 levels... from ./unit/../test_helper.rb:2 from c:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in gem_original_require' from c:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:inrequire' from unit/page_test.rb:1 Somebody an idea what´s wrong? If I don´t use devise my tests are okay. And my second question: Does somebdoy has a good tutorial for increasing different roles in the devise gem? If I generate my own views and add a few attributes to my devise-model, they won´t be save in the database. I read the docu at github, but don´t really checked it. mattherick

    Read the article

  • Net::SMTPFatalError in rails 2.3.4

    - by Brian Roisentul
    I'm getting the following error when trying to send email on rails 2.3.4(it worked on 2.3.2) using action_mailer_tls plugin: Net::SMTPFatalError in UsersController#create 555 5.5.2 Syntax error. w3sm66205164ybi.9 C:/Program Files (x86)/NetBeans 6.8/ruby2/jruby-1.4.0/lib/ruby/1.8/net/smtp.rb:930:in `check_response' C:/Program Files (x86)/NetBeans 6.8/ruby2/jruby-1.4.0/lib/ruby/1.8/net/smtp.rb:899:in `getok' C:/Program Files (x86)/NetBeans 6.8/ruby2/jruby-1.4.0/lib/ruby/1.8/net/smtp.rb:828:in `mailfrom' C:/Program Files (x86)/NetBeans 6.8/ruby2/jruby-1.4.0/lib/ruby/1.8/net/smtp.rb:653:in `send_message' C:/Ruby/lib/ruby/gems/1.8/gems/actionmailer-2.3.4/lib/action_mailer/base.rb:683:in `perform_delivery_smtp' C:/Program Files (x86)/NetBeans 6.8/ruby2/jruby-1.4.0/lib/ruby/1.8/net/smtp.rb:526:in `start' C:/Ruby/lib/ruby/gems/1.8/gems/actionmailer-2.3.4/lib/action_mailer/base.rb:681:in `perform_delivery_smtp' C:/Ruby/lib/ruby/gems/1.8/gems/actionmailer-2.3.4/lib/action_mailer/base.rb:523:in `deliver!' C:/Ruby/lib/ruby/gems/1.8/gems/actionmailer-2.3.4/lib/action_mailer/base.rb:395:in `method_missing' D:/Proyectos/Cursometro/www/app/models/user_observer.rb:3:in `after_create' D:/Proyectos/Cursometro/www/app/controllers/users_controller.rb:221:in `create_new_user' D:/Proyectos/Cursometro/www/app/controllers/users_controller.rb:101:in `create' This has happened after I changed the following line at action_mailer/

    Read the article

  • Rake db:migrate returns "rake aborted! no such file to load -- spec"

    - by Isaac Yerushalmi
    For some reason, out of no where, rails began giving me an error on "rake db:migrate", and I can no longer run migrations. It returns the error "no such file to load -- spec /home/ti/rails_apps/appname/Rakefile:10" I've spent two hours searching google for answers, trying to figure this out, but to no avail. What could be the problem? Here is the trace: -jailshell-3.2$ rake db:migrate --trace (in /home/ti/rails_apps/teamisrael) rake aborted! no such file to load -- spec /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require' /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:521:in `new_constants_in' /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require' /home/ti/rails_apps/teamisrael/vendor/plugins/google-geocoder/tasks/rspec.rake:5 /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:145:in `load_without_new_constant_marking' /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:145:in `load' /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:521:in `new_constants_in' /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:145:in `load' /usr/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/tasks/rails.rb:7 /usr/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/tasks/rails.rb:7:in `each' /usr/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/tasks/rails.rb:7 /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' /home/ti/rails_apps/teamisrael/Rakefile:10 /usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2349:in `load' /usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2349:in `raw_load_rakefile' /usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1985:in `load_rakefile' /usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2036:in `standard_exception_handling' /usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1984:in `load_rakefile' /usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1969:in `run' /usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2036:in `standard_exception_handling' /usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1967:in `run' /usr/lib/ruby/gems/1.8/gems/rake-0.8.3/bin/rake:31 /usr/local/bin/rake:19:in `load' /usr/local/bin/rake:19

    Read the article

  • Structuring a rails application with static data

    - by Morten
    I'm working on a rails application, and so far I've focused on the api and the functionality. But now I'm more and more reaching a point where I will want to add static content, descriptions of the software and help information. Information that is generally in a CMS system. How do I in the best way structure this so I can still work with the application. Yet maintaining the look and feel of the rails application? Do write a CMS in my app? That seems a bit far fetched. Are there any Gems that do this? What is the de facto standard for architecting this scenario?

    Read the article

< Previous Page | 43 44 45 46 47 48 49 50 51 52 53 54  | Next Page >