Search Results

Search found 10782 results on 432 pages for 'rails models'.

Page 13/432 | < Previous Page | 9 10 11 12 13 14 15 16 17 18 19 20  | Next Page >

  • Django's post_save signal behaves weirdly with models using multi-table inheritance

    - by hekevintran
    Django's post_save signal behaves weirdly with models using multi-table inheritance I am noticing an odd behavior in the way Django's post_save signal works when using a model that has multi-table inheritance. I have these two models: class Animal(models.Model): category = models.CharField(max_length=20) class Dog(Animal): color = models.CharField(max_length=10) I have a post save callback called echo_category: def echo_category(sender, **kwargs): print "category: '%s'" % kwargs['instance'].category post_save.connect(echo_category, sender=Dog) I have this fixture: [ { "pk": 1, "model": "animal.animal", "fields": { "category": "omnivore" } }, { "pk": 1, "model": "animal.dog", "fields": { "color": "brown" } } ] In every part of the program except for in the post_save callback the following is true: from animal.models import Dog Dog.objects.get(pk=1).category == u'omnivore' # True When I run syncdb and the fixture is installed, the echo_category function is run. The output from syncdb is: $ python manage.py syncdb --noinput Installing json fixture 'initial_data' from '~/my_proj/animal/fixtures'. category: '' Installed 2 object(s) from 1 fixture(s) The weird thing here is that the dog object's category attribute is an empty string. Why is it not 'omnivore' like it is everywhere else? As a temporary (hopefully) workaround I reload the object from the database in the post_save callback: def echo_category(sender, **kwargs): instance = kwargs['instance'] instance = sender.objects.get(pk=instance.pk) print "category: '%s'" % instance.category post_save.connect(echo_category, sender=Dog) This works but it is not something I like because I must remember to do it when the model inherits from another model and it must hit the database again. The other weird thing is that I must do instance.pk to get the primary key. The normal 'id' attribute does not work (I cannot use instance.id). I do not know why this is. Maybe this is related to the reason why the category attribute is not doing the right thing?

    Read the article

  • Can someone explain the true landscape of Rails vs PHP deployment, particularly within the context of Reseller-based web hosting (e.g., Hostgator)?

    - by rcd
    Currently, I have a reseller account with the company HostGator. I design websites, which up until now have occasionally been wrapped in Wordpress CMSs and the like (PHP applications). I then sell hosting (of the site I've designed) to the client, which is pretty simple, in that I can simply click a button and add a new shared hosting account/site with whatever settings I want. Furthermore, I then utilize WHMCS to automate billing and account management. It's a nice package and pretty simple. I pay something like $25 a month, and can sell a hundred accounts under this (because my clients bandwidth requirements are low). Now I am finding the need to develop more customized applications, including a minimalist CMS and several proprietary things. I soon anticipate developing these apps for clients as well. Thus, I've spent the past few months learning Rails, and it's coming along well now. The thing that has nagged at me all along, though, is the deployment issue. I can't wrap my brain around it. It seems like all of the popular options (Heroku, etc) have nice automation with git and are set up in the "Rails Way". I get that (sort of). But it's terribly expensive... a single dyno, a helper, and the cheapest database (which they say is mainly suitable for testing) that isn't limited to 5MB runs $51. This is for ONE app!!! Throw in a "production" DB and you're over $200. This is like... the same prices as getting a server somewhere, right? Meanwhile, going back to what I guess is a "traditional" hosting environment with Hostgator, their server only has Ruby 1.8.7 and Rails 2.3.5... No Rails 3. AND, no Passenger (not that I really understand the difference in CGI or mod_rails or whatever, but they say Passenger is the simplest). So I'm to understand that if I build an app in Rails 3, it won't run at all on this host? But damn, I already have these accounts under my reseller account there, all running static html and/or PHP stuff, right? So what now? How do I get all of this under one simple (and affordable) roof? Forgive my ignorance, but I just don't get it. Managing a VPS is cool and all, but entails learning server admin stuff and security... And it's expensive. I get that a shared and/or reseller "server-based" (forgive the terminology) may be inadequate for large-scale apps that use a lot of bandwidth... But what about for those of us who are building real (but small and low bandwidth) apps (with Rails) and who want to deploy them simply, cheaply, using the same conceptual approach as PHP? Even after learning all of this Ruby and Rails stuff for months, I'm questioning whether it's worth it when it comes to deployment. I want to build a small app, upload it to my home directory on a shared server account, and just make it run. Why should that be so hard? Am I just choosing the wrong language/framework? Forgive my ignorance in the subject; these questions are not rhetorical; just trying to learn here. So: 1) I'd appreciate if someone could give me a good rundown of how to understand deployment in Rails vs. PHP. 2) I'd appreciate if someone could address my issue with running a hosting/web business around reseller hosting (Hostgator) while also being able to host Rails apps. Can it be done? And how can a company like Hostgator completely ignore what's current in Rails/Ruby? Thanks.

    Read the article

  • How can I display a list of three different Models sortable by the same :attribute in rails?

    - by Angela
    I have a Campaign model which has_many Calls, Emails, and Letters. For now, these are each a separate Model with different controllers and actions (although I would like to start to think of ways to collapse them once the models and actions stabilize). They do share two attributes at least: :days and :title I would like a way to represent all the Calls, Emails, and Letters that belong_to a specific Campaign as a sortable collection (sortable by :days), in a way that outputs the model name and the path_to() for each. For example (I know the below is not correct, but it represents the kind of output/format I've been trying to do: @campaign_events.each do |campaign_event| <%= campaign_event.model_name %> <%= link_to campaign_event.title, #{model_name}_path(campaign_event) %> end Thanks so much. BTW, if this matters, I would then want to make the :days attribute editable_in_place.

    Read the article

  • Multiple Rails apps on same subdomain?

    - by Derek
    I recently decided to try out Rails. When working with PHP, I simply had all of my PHP projects in the same directory. For example, I may have http://ubuntu/app1, http://ubuntu/app2, etc. I created a subdomain for Rails (http://ruby.ubuntu), installed Rails and Passenger and everything is working. However, I may be wrong, but it looks like I can only have one Rails app per subdomain? My VirtualHost is as follows: <VirtualHost *:80> ServerName ruby.ubuntu ServerAdmin webmaster@localhost DocumentRoot /var/www/ruby/blog/public <Directory /var/www/ruby/blog/public> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all RailsEnv development </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> All of my PHP and misc. files are stored in /var/www/main. I want to be able to store all of my Rails apps in /var/www/ruby. I tried changing DocumentRoot to /var/www/ruby, but I don't think it's as simple as that. When I browse to a Rails app's Welcome Aboard page and click on "About my application's environment," I get a 404 page, but when the DocumentRoot is set to the public directory, I get the expected result. I don't want to have to create a new subdomain every time I create a new project. Is there any way I can make it so I can store all of my apps in /var/www/ruby, and browsing to http://ruby.ubuntu will let me access all of my Rails apps there? That way if I want to create a new app, all I have to do is rails new app, no Apache .htaccess or VirtualHost configuration required.

    Read the article

  • Rails Plugins Load Path - I have ActiveRecord Models in a Plugin, How do I load them without Namespa

    - by viatropos
    I have a bunch of models for Oauth services, things like: TwitterToken GoogleToken There are OAuth versions and OpenID versions for some, so I decided to logically organize my gem like so: lib lib/my-auth-gem lib/my-auth-gem/oauth lib/my-auth-gem/oauth/tokens/google_token ... lib/my-auth-gem/openid/tokens/google_token ... I would like to be able to name my models GoogleToken, rather than MyAuthGem::Oauth::Tokens::GoogleToken. How do I do that? This will be for Rails 2.3+ and Rails 3.

    Read the article

  • Splitting up a Rails/Ruby app onto multiple servers

    - by craig.kaminsky
    We recently moved a large application to two machines, both running the same codebase. I. Machine A Web server for public facing application Receives web hook call backs from our ESP Handles a few large, list-processing jobs (uploaded spreadsheets with data) II. Machine B Manages a massive set of (background) jobs but, primarily, focuses on building and assembling newsletters Runs all integration with our NetSuite platform Runs all system maintenance (read: DB) jobs To me, having these two apps running the same codebase (a large, monolithic Rails application) seems 'wrong'. I am wondering if anyone has advice on how to better break up the code for these two apps. While they both need the same DB and, ultimately, the same model code, Machine B has no need for Controllers and Views and it feels wasteful running a full-stack Rails app for its tasks. A couple things came to mind but I'm not sure if I'm trying to solve a problem that doesn't exist: Break the models out into a sub-module on git and include into both apps Build out the Mahcine B app in plain Ruby or a lighter framework like Sinatra (where I could use ActiveRecord with Sinatra in combo with a sub-module for the model folder). I'm new to this scenario and appreciate any and all feedback or direction! Thank you.

    Read the article

  • Error whilst starting rails server

    - by Sajeer
    I am new to rails and the bundle install works fine for the project. but when I start the rails server errors are shown.The shown errors are attached herewith. Exiting C:/Ruby193/lib/ruby/1.9.1/psych.rb:203:in `parse': (): could not find e xpected ':' while scanning a simple key at line 27 column 3 (Psych::SyntaxError) from C:/Ruby193/lib/ruby/1.9.1/psych.rb:203:in `parse_stream' from C:/Ruby193/lib/ruby/1.9.1/psych.rb:151:in `parse' from C:/Ruby193/lib/ruby/1.9.1/psych.rb:127:in `load' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.2/lib/rails/applic ation/configuration.rb:115:in database_configuration' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.2/lib/active_r ecord/railtie.rb:75:inblock (2 levels) in ' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.2/lib/active_ support/lazy_load_hooks.rb:36:in instance_eval' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.2/lib/active_ support/lazy_load_hooks.rb:36:inexecute_hook' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.2/lib/active_ support/lazy_load_hooks.rb:26:in on_load' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.2/lib/active_r ecord/railtie.rb:74:inblock in ' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.2/lib/rails/initia lizable.rb:30:in instance_exec' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.2/lib/rails/initia lizable.rb:30:inrun' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.2/lib/rails/initia lizable.rb:55:in block in run_initializers' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.2/lib/rails/initia lizable.rb:54:ineach' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.2/lib/rails/initia lizable.rb:54:in run_initializers' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.2/lib/rails/applic ation.rb:136:ininitialize!' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.2/lib/rails/railti e/configurable.rb:30:in method_missing' from D:/ROR/appmallserver/config/environment.rb:22:in' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.2/lib/active_ support/dependencies.rb:251:in require' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.2/lib/active_ support/dependencies.rb:251:inblock in require' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.2/lib/active_ support/dependencies.rb:236:in load_dependency' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.2/lib/active_ support/dependencies.rb:251:inrequire' from D:/ROR/appmallserver/config.ru:4:in block in <main>' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb: 51:ininstance_eval' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb: 51:in initialize' from D:/ROR/appmallserver/config.ru:1:innew' from D:/ROR/appmallserver/config.ru:1:in <main>' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb: 40:ineval' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb: 40:in parse_file' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/server.rb:2 00:inapp' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.2/lib/rails/comman ds/server.rb:46:in app' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/server.rb:3 01:inwrapped_app' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/server.rb:2 52:in start' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.2/lib/rails/comman ds/server.rb:70:instart' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.2/lib/rails/comman ds.rb:55:in block in <top (required)>' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.2/lib/rails/comman ds.rb:50:intap' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.2/lib/rails/comman ds.rb:50:in <top (required)>' from script/rails:21:inrequire' from script/rails:21:in `'

    Read the article

  • Rails: The Law of Demeter [duplicate]

    - by user2158382
    This question already has an answer here: Rails: Law of Demeter Confusion 4 answers I am reading a book called Rails AntiPatterns and they talk about using delegation to to avoid breaking the Law of Demeter. Here is their prime example: They believe that calling something like this in the controller is bad (and I agree) @street = @invoice.customer.address.street Their proposed solution is to do the following: class Customer has_one :address belongs_to :invoice def street address.street end end class Invoice has_one :customer def customer_street customer.street end end @street = @invoice.customer_street They are stating that since you only use one dot, you are not breaking the Law of Demeter here. I think this is incorrect, because you are still going through customer to go through address to get the invoice's street. I primarily got this idea from a blog post I read: http://www.dan-manges.com/blog/37 In the blog post the prime example is class Wallet attr_accessor :cash end class Customer has_one :wallet # attribute delegation def cash @wallet.cash end end class Paperboy def collect_money(customer, due_amount) if customer.cash < due_ammount raise InsufficientFundsError else customer.cash -= due_amount @collected_amount += due_amount end end end The blog post states that although there is only one dot customer.cash instead of customer.wallet.cash, this code still violates the Law of Demeter. Now in the Paperboy collect_money method, we don't have two dots, we just have one in "customer.cash". Has this delegation solved our problem? Not at all. If we look at the behavior, a paperboy is still reaching directly into a customer's wallet to get cash out. EDIT I completely understand and agree that this is still a violation and I need to create a method in Wallet called withdraw that handles the payment for me and that I should call that method inside the Customer class. What I don't get is that according to this process, my first example still violates the Law of Demeter because Invoice is still reaching directly into Customer to get the street. Can somebody help me clear the confusion. I have been searching for the past 2 days trying to let this topic sink in, but it is still confusing.

    Read the article

  • Roo gem .xlsx files performance problems [closed]

    - by alvaritogf
    I am getting unacceptable performace problems by using the roo gem for reading a file by using XLSX or XLS library from this gem. Someone may suggest me an alternative about how to parse an .XLSX file? parsed_file = Excel.new(filename,false, :ignore) if (file_format.upcase == "XLS") parsed_file = Excelx.new(filename,false, :ignore) if (file_format.upcase == "XLSX") raise t "#{filename} is not an Excel file!" if (!parsed_file) parsed_file.default_sheet = parsed_file.sheets[0]#'Sheet2'#oo.sheets[1] first_row = parsed_file.first_row last_row = parsed_file.last_row first_column = parsed_file.first_column last_column = parsed_file.last_column #logger.info "#### Total Rows:#{last_row}, first_row:#{first_row}, last_row:#{last_row}, first_column:#{first_column}, last_column:#{last_column}" first_row.upto(last_row) do |current_line| # Stuff .... end Thanks

    Read the article

  • What is the best place to go to ask questions about Aptana RadRails environment and setup problems?

    - by larson4
    I am having some issues using RadRails and the RadRails support site is not getting me any answers (I've had questions up for days with no response which StackOverflow has conditioned me to find unacceptable!). Primarily I have questions about things like exceptions thrown when running the project or mismatches between instructions and reality. Can I ask these questions on Programmers.stackexchange? Or Stackoverflow? Or can anyone recommend an active RadRails forumn somewhere?

    Read the article

  • Using amCharts in Ruby on Rails

    - by Dexter
    I have followed this tutorial in order to use amChart and it worked with no problems , now I am trying to generate a chart with amCharts to show each user and the sign in count but i cant make it work because it not getting the data correctly, what i am missing here ? how can i show user email and sign_in_count ? Users_controller.rb class UsersController < ApplicationController load_and_authorize_resource def index @users = User.all respond_to do |format| format.html # index.html.erb format.json { render :json => @users } end end def show @user = User.find(params[:id]) end def new @user = User.new end def create @user = User.new(params[:user]) if @user.save flash[:notice] = 'A new user created successfully.' redirect_to users_path else flash[:error] = 'An error occurred please try again!' redirect_to users_path end end def edit @user = User.find(params[:id]) end def update @user = User.find(params[:id]) if @user.update_attributes(params[:user]) flash[:notice] = 'Profile updated' redirect_to users_path else render 'edit' end end def destroy @user = User.find(params[:id]) if current_user == (@user) flash[:error] = "Admin suicide warning: Can't delete yourself." else @user.destroy flash[:notice] = 'User deleted' redirect_to users_path end end def checkname if User.where('user_name = ?', params[:user]).count == 0 render :nothing => true, :status => 200 else render :nothing => true, :status => 409 end return end end Users_helper.rb module UsersHelper def convert_to_amcharts_json(data_array) data_array.to_json.gsub(/\"text\"/, "text").html_safe end end index.html.erb <div id="chartdiv" style="width: 100%; height: 400px;"></div> <script type="text/javascript"> var chart; var chartData = <%= convert_to_amcharts_json(@users) %>; AmCharts.ready(function () { // SERIAL CHART chart = new AmCharts.AmSerialChart(); chart.dataProvider = chartData; chart.categoryField = "email"; // the following two lines makes chart 3D chart.depth3D = 20; chart.angle = 30; // AXES // category var categoryAxis = chart.categoryAxis; categoryAxis.labelRotation = 90; categoryAxis.dashLength = 5; categoryAxis.gridPosition = "start"; // value var valueAxis = new AmCharts.ValueAxis(); valueAxis.title = "Most Active users"; valueAxis.dashLength = 5; chart.addValueAxis(valueAxis); // GRAPH var graph = new AmCharts.AmGraph(); graph.valueField = "sign_in_count"; graph.colorField = "color"; graph.balloonText = "<span style='font-size:14px'>[[category]]: <b>[[value]]</b></span>"; graph.type = "column"; graph.lineAlpha = 0; graph.fillAlphas = 1; chart.addGraph(graph); // CURSOR var chartCursor = new AmCharts.ChartCursor(); chartCursor.cursorAlpha = 0; chartCursor.zoomable = false; chartCursor.categoryBalloonEnabled = false; chart.addChartCursor(chartCursor); // WRITE chart.write("chartdiv"); }); </script>

    Read the article

  • Rails : soap4r - Error while running wsdl2ruby.rb

    - by Mathieu
    when I execute Mathieu$ /Users/Mathieu/.gem/ruby/1.8/bin/wsdl2ruby.rb path --wsdl https://www.arello.com/webservice/verify.cfc?wsdl --type client --force I get at depth 0 - 20: unable to get local issuer certificate F, [2010-05-06T10:41:11.040288 #35933] FATAL -- app: Detected an exception. Stopping ... SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (OpenSSL::SSL::SSLError) /Users/Mathieu/.gem/ruby/1.8/gems/httpclient-2.1.5.2/lib/httpclient/session.rb:247:in connect' /Users/Mathieu/.gem/ruby/1.8/gems/httpclient-2.1.5.2/lib/httpclient/session.rb:247:inssl_connect' /Users/Mathieu/.gem/ruby/1.8/gems/httpclient-2.1.5.2/lib/httpclient/session.rb:639:in connect' /Users/Mathieu/.gem/ruby/1.8/gems/httpclient-2.1.5.2/lib/httpclient/timeout.rb:128:intimeout' /Users/Mathieu/.gem/ruby/1.8/gems/httpclient-2.1.5.2/lib/httpclient/session.rb:631:in connect' /Users/Mathieu/.gem/ruby/1.8/gems/httpclient-2.1.5.2/lib/httpclient/session.rb:522:inquery' /Users/Mathieu/.gem/ruby/1.8/gems/httpclient-2.1.5.2/lib/httpclient/session.rb:147:in query' /Users/Mathieu/.gem/ruby/1.8/gems/httpclient-2.1.5.2/lib/httpclient.rb:953:indo_get_block' /Users/Mathieu/.gem/ruby/1.8/gems/httpclient-2.1.5.2/lib/httpclient.rb:765:in do_request' /Users/Mathieu/.gem/ruby/1.8/gems/httpclient-2.1.5.2/lib/httpclient.rb:848:inprotect_keep_alive_disconnected' /Users/Mathieu/.gem/ruby/1.8/gems/httpclient-2.1.5.2/lib/httpclient.rb:764:in do_request' /Users/Mathieu/.gem/ruby/1.8/gems/httpclient-2.1.5.2/lib/httpclient.rb:833:infollow_redirect' /Users/Mathieu/.gem/ruby/1.8/gems/httpclient-2.1.5.2/lib/httpclient.rb:519:in get_content' /Users/Mathieu/.gem/ruby/1.8/gems/soap4r-1.5.8/lib/wsdl/xmlSchema/importer.rb:73:infetch' /Users/Mathieu/.gem/ruby/1.8/gems/soap4r-1.5.8/lib/wsdl/xmlSchema/importer.rb:36:in import' /Users/Mathieu/.gem/ruby/1.8/gems/soap4r-1.5.8/lib/wsdl/importer.rb:18:inimport' /Users/Mathieu/.gem/ruby/1.8/gems/soap4r-1.5.8/lib/wsdl/soap/wsdl2ruby.rb:206:in import' /Users/Mathieu/.gem/ruby/1.8/gems/soap4r-1.5.8/lib/wsdl/soap/wsdl2ruby.rb:36:inrun' /Users/Mathieu/.gem/ruby/1.8/gems/soap4r-1.5.8/bin/wsdl2ruby.rb:46:in run' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/logger.rb:659:instart' /Users/Mathieu/.gem/ruby/1.8/gems/soap4r-1.5.8/bin/wsdl2ruby.rb:137 /Users/Mathieu/.gem/ruby/1.8/bin/wsdl2ruby.rb:19:in `load' /Users/Mathieu/.gem/ruby/1.8/bin/wsdl2ruby.rb:19 I, [2010-05-06T10:41:11.040855 #35933] INFO -- app: End of app. (status: -1)

    Read the article

  • Dotrine::Zend::How generate new doctrine models without delete doctrine models classes with my code

    - by Yosef
    Hi, I build zend app with doctrine. The problem is when i add new tables to database and I should generate doctrine models, because I add my own code to Doctine generated classes- I dont wont to delete them. I solve this problem like that: 1. copy old generated doctine models classes to other folder 2. generate doctrine models from database 3. remove same new doctrine models class with old I think my solution stupied, but i cant think about something else. Please help me, Thanks, Yosef

    Read the article

  • How to use Railroad to create a models diagram that show methods

    - by SeeBees
    Railroad is a great UML tool for Ruby on Rails. It can automatically generate class diagrams of models and controllers. For models, a railroad-generated class diagram shows attributes of each model and the associations between one model and another. A sample diagram can be found here. It is very useful for a developer to see attributes and associations of models. While attributes and associations reveal the inner states and relationships of models, methods specify their behaviours. They are all desirable in a class diagram. I would like railroad to generate a class diagram that also lists methods for models, which will help me to know what each model does. I know methods are displayed in a diagram that is generated for controllers, but I don't see such an option for a diagram of models. Does someone know how to do that with railroad? Or is that possible? Thanks!

    Read the article

  • Per-User basis security with restful_authentication in Rails ?

    - by benoror
    Hi! I'm using restful_authentication plugin, but I would like to have per-user security, for example: class PostsController < ApplicationController # Login required before_filter :login_required, :except => [ :index, :show ] # Only the same user can create, edit and delete their own posts before_filter :only_by_same_user, :only => [ :create, :update, :destroy ] end Thanks!

    Read the article

  • Rails validation "failing when succeeding"

    - by Fredrik
    I have this in my user.rb: attr_accessor :old_password def validate unless password.nil? errors.add_to_base("Old password entered incorrect") unless self.valid_password? old_password end end I have old_password as a a virtual attribute that has to be validated as matching with the current before updating to a new password. My problem is that upon correct entering ( password == password confirmation and self.valid_password? old_password ) an error will yield and pass me back to the form. The strange part is that the data will actually be updated in the database, and it will not on wrong input; although it will yield the very same error ("Old password entered incorrect"). What on earth am I doing wrong?

    Read the article

  • Did we really always need to use Ruby/ rails plugin?

    - by Devlim
    I been intersted in ruby and rails lately but what I always encounter in blog/ podcast / book is they will always teach how to use ruby or rails plugin/ ruby instead of writing one. Did we really always need to use plugin, even thing like authorization? Authenticate? Is it really waste time Or hard to write from start? Then if it hard and waste time why rails say make web development less painful? Or I was wrong in term of concept? Goal ? Or anything else? Of rails? Anyone can guide me ?

    Read the article

  • Where to put reusable methods for access by controllers in rails

    - by 99miles
    I have several methods I call from my controllers that feel like they should be pulled out and put into a reusable class, outside of the controller. Where do people usually put this stuff? I know I can put them into my ApplicationController, but that doesn't seem to be a great solution if I think I can use these methods later in other applications. Also, I have a bunch of utility methods in my controllers that likely won't be used in other controllers, or in the future at all, but I feel like they just bloat my controller a bit. Do people usually move these out someplace for cleanliness or just end up with a huge controller? I'm coming from Java and Actionscript where I'd just create new util classes for this stuff.

    Read the article

  • rails inverting to_xml and getting the original model

    - by djacobs7
    I did this: [User.first, User.last].to_xml and got this: <users type="array"> <user> <created-at type="datetime">2010-03-16T06:40:51Z</created-at> <id type="integer">3</id> <password-hash></password-hash> <salt></salt> <updated-at type="datetime">2010-03-16T06:40:51Z</updated-at> <username nil="true"></username> </user> <user> <created-at type="datetime">2010-03-23T03:58:15Z</created-at> <id type="integer">7</id> <password-hash></password-hash> <salt></salt> <tutorial-state nil="true"></tutorial-state> <updated-at type="datetime">2010-03-23T03:58:15Z</updated-at> <username nil="true"></username> </user> </users> How can I take that string of xml and invert it to get the original activerecord objects back?

    Read the article

  • Default values for model fields in a Ruby on Rails form

    - by Callum Rogers
    I have a Model which has fields username, data, tags, date, votes. I have form using form_for that creates a new item and puts it into the database. However, as you can guess I want the votes field to equal 0 and the date field to equal the current date when it is placed into the database. How and where would I set/apply these values to the item? I can get it to work with hidden fields in the form but this comes with obvious issues (someone could set the votes field to a massive number.

    Read the article

  • Rails 3.2 Ajax Update Div when Text Field Populated

    - by ctilley79
    In the end I would like a text field that passes a client_id to the partial. I would like to do this asynchronously so the shipment_products partial would dynamically change when the textfield value was updated. What is the best way to do this? In index.html.erb <!-- Text Field Here--> <div id="available_products"> <%= render "shipment_products" %> </div> In _shipment_products.html.erb <div id="shipment_products_container"> <h3>Assign Products to Ship<\h3> <ul class="shipment_products" id="shipment_products"> <% Product.by_client(client_id).each do |product|%> <!-- TextField value passed here --> <%= content_tag_for :li, product, :value => product.id do %> <%= hidden_field_tag("shipment[product_ids][]", product.id) %> <%= product.product_name %> <% end %> <% end %> <\ul> </div> This is similar to what I want in the end.

    Read the article

  • Ruby on Rails: strange voting increment behavior

    - by Justin Meltzer
    So I have an up and a downvote button that inserts a vote with a value of 1 or -1 into the database. This works correctly. Then, I display the total vote count for that element by summing up its votes' values. However, this isn't working correctly, because the vote sum display is acting really strange: The first vote on a video doesn't seem to increment it at all. Then the second vote does. If I go from an upvote to a downvote, it increments up once, and then the next downvote is down. This is difficult to explain, but maybe you can figure out what is wrong with my code. I have this function in my Video model (the element that is voted on, it has_many video_votes): def vote_sum read_attribute(:vote_sum) || video_votes.sum(:value) end I also have this in my VideoVote model: after_create :update_vote_sum private def update_vote_sum video.update_attributes(:vote_sum => video.vote_sum + value) end What am I doing wrong?

    Read the article

  • Disturbing Ruby on Rails Behavior

    - by User
    Environment.rb ActionMailer::Base.delivery_method = :sendmail ActionMailer::Base.sendmail_settings = { :address => "mail.example.org", :domain => "example.org", :port => 25, :authentication => :login, :user_name => "email+email.org", :password => "password" } ActionMailer::Base.perform_deliveries = true ActionMailer::Base.raise_delivery_errors = true ActionMailer::Base.default_charset = "utf-8" Development.log Sent mail to [email protected] Date: Sat, 17 Apr 2010 19:38:08 -0500 From: example.org To: [email protected] Subject: Hello Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 The process of sending email is ok but when I check my email I didn't recive any. What seems to be wrong?

    Read the article

< Previous Page | 9 10 11 12 13 14 15 16 17 18 19 20  | Next Page >