Search Results

Search found 6941 results on 278 pages for 'drupal views'.

Page 65/278 | < Previous Page | 61 62 63 64 65 66 67 68 69 70 71 72  | Next Page >

  • dependent: :destroy is not deleting dependencies from views

    - by jxdx
    Projects have many rooms. When I delete a project from the view, the associated rooms are not deleted. Rooms also have many products which should also be deleted when a project is deleted. Project class class Project < ActiveRecord::Base belongs_to :user has_many :rooms, dependent: :destroy has_many :products, through: :rooms end Projects Controller class ProjectsController < ApplicationController def destroy @project = current_user.projects.find(params[:id]) if @project.delete redirect_to user_projects_path(@project.user) end end end Rooms Controller class RoomsController < ApplicationController def destroy @room = Room.find(params[:id]) if @room.delete redirect_to root_path end end The delete link in the projects show view. = link_to "Delete", project_room_path(room.project, room), method: :delete, data: { confirm: "Are you sure?" }, title: room.title, class: "btn btn-danger"

    Read the article

  • how to create 2 controllers with same actionresult 2 views but one implementation

    - by amalatsliit
    I got a controller in my mvc application like below. public class BaseController: Controller { protected void LogInfo() { logger.InfoFormat("[SessionID: {0}, RemoteIP: {1}]", Session.SessionID, Request.UserHostAddress); } } public class FirstController : BaseController { public ActionResult Index(string name) { LogInfo(); getQueryString(); if(IsValidRec()) { if(Errors())) { return View("Error"); } var viewname = getViewName(name); return view(viewname); } else return view("NotFound"); } } I need to create another controller(SecondController ) with same ActionResult method that FirstController has but without any implementation. Because I dont wont to repeat same code in 2 ActionResult methods. what is the best way to do that. I tried in following way but I m getting error when I initialize my protected method 'LogInfo()' public class SecondController : BaseController { public ActionResult Index(string name) { var firstcontroller = new FirstController(); return firstcontroller.Index(name); } }

    Read the article

  • Pass database data to multiples views-Laravel

    - by user3696018
    I have a database with details of daily sales. To query a database, I have a form in a view with parameters that will query as date of admission, client and others. The result is shown in another view with the daily details of income, and below is a summary of the article do all entered. The summary I wish to transfer to another view, try to view :: composer but only transfer the empty query (I saw it with debug bar). Just appeared an empty view. How I can transfer data from the database without the latter view is empty? The second html view is totaly diferent , only the data is the same.

    Read the article

  • Numerology with Python And Django

    - by Asinox
    Hi guys, i have a function that give me the result that im expecting in console mode, but if i try to use the function with Django, the page never load and just have a loop calculating and never end. Any idea ? *sorry with my english Console function (WORK GREAT): def sum_digitos(n): sum = 0; while n != 0: sum += n % 10 n /= 10 if sum > 9: x = str(sum) y =list(x) sum = int(y[0]) + int(y[1]) return sum print sum_digitos(2461978) Django views: def Calcular(request): if request.method == 'POST': form = NumerologiaForm(request.POST) if form.is_valid(): sum = 0; ano = str(request.POST['fecha_year']) mes = str(request.POST['fecha_month']) dia = str(request.POST['fecha_day']) data = dia + mes + ano fecha = int(data) while fecha != 0: f = fecha sum += f % 10 f /= 10 if sum > 9: x = str(sum) y =list(x) sum = int(y[0]) + int(y[1]) resultado = get_object_or_404(Numero,numero = sum) return HttpResponseRedirect(resultado.get_absolute_url()) else: form = NumerologiaForm() return render_to_response('numerologiaForm.html',{'form':form})

    Read the article

  • Problem showing modelstate errors while using RenderPartialToString

    - by Martin
    Im using the following code: public string RenderPartialToString(ControllerContext context, string partialViewName, ViewDataDictionary viewData, TempDataDictionary tempData) { ViewEngineResult result = ViewEngines.Engines.FindPartialView(context, partialViewName); if (result.View != null) { StringBuilder sb = new StringBuilder(); using (StringWriter sw = new StringWriter(sb)) { using (HtmlTextWriter output = new HtmlTextWriter(sw)) { ViewContext viewContext = new ViewContext(context, result.View, viewData, tempData, output); result.View.Render(viewContext, output); } } return sb.ToString(); } return String.Empty; } To return a partial view and a form through JSON. It works as it should, but as soon as I get modelstate errors my ValidationSummary does not show. The JSON only return the default form but it does not highlight the validation errors or show the validation summary. Am I missing something? This is how I call the RenderPartialToString: string partialView = RenderPartialToString(this.ControllerContext, "~/Areas/User/Views/Account/ChangeAccountDetails.ascx", new ViewDataDictionary(avd), new TempDataDictionary());

    Read the article

  • Error about 'invalid JSON' with couchDB view but the json's fine...

    - by Chris Huang-Leaver
    I am trying to setup the following view on CouchDB { "_id":"_design/id", "_rev":"1-9be2e55e05ac368da3047841f301203d", "language":"javascript", "views":{ "by_id":{ "map" : "function(doc) { emit(doc.id, doc)}" },"from_user_id":{ "map" : "function(doc) { if (doc.from_user_id) {emit(doc.from_user_id, doc)}}"}, "from_user":{ "map" : "function(doc) { if (doc.from_user) {emit(doc.from_user, doc)}}"}, "to_user_id":{ "map" : "function(doc) {if (doc.to_user_id){ emit(doc.to_user_id, doc)}}"}, "to_user":{ "map" : "function(doc) {if (doc.to_user){ emit(doc.to_user, doc)}}" }, "max_id":{ "map" : "function(doc) { if (doc.id) {emit(doc._id, eval(doc.id))}}", "reduce" :"function(key,value) { a = value[0]; for (i=1; i <value.length; ++i){a = Math.max(a,value[i])} return a}" } } } when I try to 'PUT' this using curl: curl -X PUT -d keys.json $CDB/_design/id {"error":"bad_request","reason":"invalid UTF-8 JSON"} I know it's not invalid JSON, because I tested it using the 'json' library built into Python 2.6, it loads fine. JS screw ups give me the error 'must evaluate to a function' What else might be wrong with it?

    Read the article

  • Django foreign key question

    - by Hulk
    All, i have the following model defined, class header(models.Model): title = models.CharField(max_length = 255) created_by = models.CharField(max_length = 255) def __unicode__(self): return self.id() class criteria(models.Model): details = models.CharField(max_length = 255) headerid = models.ForeignKey(header) def __unicode__(self): return self.id() class options(models.Model): opt_details = models.CharField(max_length = 255) headerid = models.ForeignKey(header) def __unicode__(self): return self.id() AND IN MY VIEWS I HAVE p= header(title=name,created_by=id) p.save() Now the data will be saved to header table .My question is that for this id generated in header table how will save the data to criteria and options table..Please let me know.. Thanks..

    Read the article

  • Django javascript escape characters

    - by Hulk
    There is a text area in which the data is entered as, 122 //Enter button pushed Address Name //Enter button pushed 1 And the same is tored in the db.And the data is fetched in views and returned it to template as, <script> {% for i in dict.row_arr %} var ii= ('{{ i }}'); row_arr.push( ii ); {% endfor %} </script> Here there is an error as Error: unterminated string literal Line: 40, Column: 12 Source Code: var ii= ('1212 And when the html source shows up as, var ii= ('1212 1 21 11212121212'); row_arr.push( ii ); How should the escape function be applied here. Thanks..

    Read the article

  • Django models avaoid duplicates

    - by Hulk
    In models, class Getdata(models.Model): title = models.CharField(max_length=255) state = models.CharField(max_length=2, choices=STATE, default="0") name = models.ForeignKey(School) created_by = models.ForeignKey(profile) def __unicode__(self): return self.id() In templates <form> <input type="submit" save the data/> </form> If the user clicks on the save button and the above data is saved in the table how to avoid the duplicates,i.e, if the user again clicks on the same submit button there should not be another entry for the same values.Or is it some this that has to be handeled in views Thanks..

    Read the article

  • Django models avoid duplicates

    - by Hulk
    In models, class Getdata(models.Model): title = models.CharField(max_length=255) state = models.CharField(max_length=2, choices=STATE, default="0") name = models.ForeignKey(School) created_by = models.ForeignKey(profile) def __unicode__(self): return self.id() In templates <form> <input type="submit" save the data/> </form> If the user clicks on the save button and the above data is saved in the table how to avoid the duplicates,i.e, if the user again clicks on the same submit button there should not be another entry for the same values.Or is it some this that has to be handeled in views Thanks..

    Read the article

  • ASP.NET MVC: Is it "wrong" to use HTTP 500 via an AJAX request to return invalid form content?

    - by Daniel Schaffer
    Here's the situation: I've got two partial views. One has a form. What needs to happen is when the form is posted via an AJAX request, if the operation succeeds, the area with the second partial is repopulated with the content. However, if the posted data was invalid, the original partial is repopulated with an error message. I'm using jQuery and the ajaxForm plugin to handle the form posts and responses. Would it be "wrong"/bad coding/wtf-worthy to conditionally use $.html() to replace the content in one area when it's a 200, and a different area if it's a 500? To me, this idea smells, but I'm not sure how else to accomplish the goal.

    Read the article

  • counter variable not working?

    - by jaycode
    Just like many things in rails, sometimes it works, sometimes it doesn't... Showing app/views/admin/products/_variant.html.erb where line #8 raised: undefined local variable or method `variant_counter' for #<ActionView::Base:0x107f7ae10> I only want to display variant_counter from partial _variant. This was the render caller code: <%= render :partial => '/admin/products/variant', :collection => product.variants %> The funny thing is, I have been using partial counter heaps number of times, somehow now I encountered this issue. Could anybody point me out what are there to find out what may went wrong?

    Read the article

  • Switch from a View (Login) to another View with a TabBarController

    - by Raphael
    Hi, i'm new at Iphone SDK Developing and now i need some help. I have a LoginView where the User have to authentificate his legitimacy. After he enter his Username and Passwort he click on the "Sign In" Button. Then i want to load my "Real-App". Here is the Problem because i can't switch from the LoginScreen to the TabBarController. I found many solutions but only for switching to other views. Is there a way to do it ?

    Read the article

  • How do I do a grouping by year?

    - by kibyegn
    I have a books model with a date type column named publish_date. On my views I'm iterating through the books and I want to group the books by year such that I have a heading for every year and books that were published on that year to be listed below the year heading. So by starting with "2010" all books published on 2010 would be listed, then another heading "2009" with all books published in 2009 listed below it and so forth. <% @all_books.each do |book| %> <%=link_to book.title + ", (PDF, " + get_file_size(book.size) + ")" %> <% end %> By doing a book.publish_date.strftime("%Y") I am able to get the year but I do not know how to group the entries by year. Any help on this would be appreciated.

    Read the article

  • How do I get selected background color from SecondView to pass to FirstView?

    - by rob
    I am going insane! This is a simple app with two Views. FirstView is a text field with info button to flip to SecondView. In SecondView I have 6 buttons for background color choice. When button is pushed the color of background changes perfectly but cannot make it also change background color for FirstView. Any help would be GREAT! Thanks! I am using Objective C class working on a iPhone app. Sorry new at this. The SecondView acts almost like a settings page in the fact that when a button is pushed the background color changes to the button color. I need it so when I push the "back" button to go back to FirstView the background color has also changed to that color choice. Been thru sooooooooo many tutorials and codes that now I am totally lost......... Thanks again!

    Read the article

  • How do I use master page container in partial view

    - by user200295
    I have several partial views with Javascript that I am trying to move to the bottom of the page. To do this I am trying to use a container in the master page Master Page - <asp:ContentPlaceHolder ID="Foot" runat="server"></asp:ContentPlaceHolder> Partial view(ascx) <asp:Content ID="header" ContentPlaceHolderID="head" runat="server"> ... </asp:Content> But I get this error Parser Error Message: Content controls have to be top-level controls in a content page or a nested master page that references a master page. So how do I ensure that the Javascript for the partial view is at the bottom of the page? Especially in cases where the html layout needs to be at the top of the page?

    Read the article

  • Best way to manage a header navigation menu from within a template?

    - by Stefan Kendall
    I'm looking to put navigation in my GSP template, and I would like to set the active class on the navigation elements for each respective page. What's the best way to do this? I have several .gsp views merging with a single template that looks like this: <div id="bd" role="main"> <div role="navigation" class="yui-g"> <ul id="nav"><a href="index.gsp"><li class="active">Home</li></a><a href = "products.gsp"><li>Products</li></a><a href = "contacts.gsp"><li>Contact</li></a></ul> </div> <g:layoutBody/> </div>

    Read the article

  • Dynamically render partial templates using mustache

    - by btakita
    Is there a way to dynamically inject partial templates (and have it work the same way in both Ruby & Javascript)? Basically, I'm trying to render different types of objects in a list. The best I can come up with is this: <div class="items"> {{#items}} <div class="item"> {{#is_message}} {{< message}} {{/is_message}} {{^is_message}} {{#is_picture}} {{< picture}} {{/is_picture}} {{^is_picture}} {{/is_picture}} {{/is_message}} </div> {{/items}} </div> For obvious reasons, I'm not super-psyched about this approach. Is there a better way? Also note that the different types of models for the views can have non-similar fields. I suppose I could always go to the lowest common denominator and have the data hash contain the html, however I would rather use the mustache templates.

    Read the article

  • Passing Values from a View to itself with parameters getting null values ?

    - by vsj
    Hi all, I am trying to get values from a view which i have the code below and I am taking the start date value from the view input text box and posting it back but I am still getting null except for the apikey and userkey.Here are the two views.. public ActionResult View1(string apiKey, string userId) { StartGoalViewModel vm = new StartGoalViewModel(); vm.ApiKey = apiKey; vm.UserId = userId; vm.GoalTypeId =1; vm.StartDate = null; return View(vm); } VIEW1.ASPX <% Html.BeginForm(); %> <%= Html.TextBox("name", Model.StartDate) %> <input type="submit" value="Start" /> <% Html.EndForm(); %> [HttpPost] public ActionResult VIEW1 (StartGoalViewModel fm) { // I get StartDate null... }

    Read the article

  • What is an alternative to eval in this situation?

    - by CppLearner
    Many of my view functions do similar things. For the most part, they reverse to a different views upon clicking a button / a text link. So I wrote a helper function render_reverse def render_reverse(f, args): # args are all string type return eval('reverse(' + f + ', ' + args + ')' ) eval is a bad practice, and is pretty slow. It takes 3 seconds to start redirecting, whereas calling reverse directly takes less than 1 second to start redirecting. What alternative do I have? By the way, the function above doesn't work properly. I was modelling after this line (which works) eval('reverse("homepage", args=["abcdefg"])') Thanks.

    Read the article

  • How to speed up Cygwin?

    - by tester
    I have been running drush scripts (for drupal) with cygwin on my relatively fast windows machine, but I still have to wait about a minute for any drush command (specifically drush cache clear to execute). I'm quite sure it has something to do with the speed of cygwin since my fellow developers (who are running linux) can run these scripts in about 5 seconds. Is there a way to make cygwin use more memory and/or cpu per terminal?

    Read the article

  • Adding Facebook Log in button to PHP code

    - by CMaury
    I am trying to add the new Facebook log in button to my registration page on my Drupal site. I know the following code is wrong, but I don't know the right syntax to implement it: function facebook_user($op, &$edit, &$user, $category = NULL) { switch($op) { // User is registering. case 'register': // Add a Facebook login button. echo ' '; } } What should I use instead of echo? Is there another way I should be going about this? Thanks

    Read the article

  • Sysadmin 101: How can I figure out why my server crashes and monitor performance?

    - by bflora
    I have a Drupal-powered site that seems to have neverending performance problems. It was butt-slow about 5 months ago. I brought in some guys who installed nginx for anonymous visitors, ajaxified a few queries so they wouldn't fire during page load, and helped me find a few bottlenecks in the code. For about a month, the site was significantly faster, though not "fast" by any stretch of the word. Meanwhile, I'm now shelling out $400/month to Slicehost to host a site that gets less than 5,000/uniques a day. Yes, you read that right. Go Drupal. Recently the site started crashing again and is slow again. I can't afford to hire people to come in, study my code from top to bottom, and make changes that may or may not help anymore. And I can't afford to throw more hardware at the problem. So I need to figure out what the problem is myself. Questions: When apache crashes, is it possible to find out what caused it to crash? There has to be a way, right? If so, how can I do this? Is there software I can use that will tell me which process caused my server to die? (e.g. "Apache crashed because someone visited page X." or "Apache crashed because you were importing too many RSS items from feed X.") There's got to be a way to learn this, right? What's a good, noob-friendly way to monitor my current apache performance? My developer friends tell me to "just use Top, dude," but Top shows me a bunch of numbers without any context. I have no clue what qualifies as a bad number or a good number in Top, or which processes are relevant and which aren't. Are there any noob-friendly server monitoring tools out there? Ideally, I could have a page that would give me a color-coded indicator about how apache is performing and then show me a list of processes or pages that are sucking right now. This way, I could know when performance is bad and then what's causing it to be so bad. Why does PHP memory matter? My apparently has a 30MB memory foot print. Will it run faster if I bring that number down? Thanks for any advice. I spent a year or so trying to boost my advertising income so I could hire a contractor to solve my performance woes. I didn't want to have to learn all this sysadmin voodoo. I'm now resigned to the fact that might not have a choice.

    Read the article

  • hook_user not being called for 'login' operation

    - by Allain Lalonde
    I've read in the drupal documentation that hook_user should be invoked for the login operation. To test this I've added a call to drupal_set_message at the top of my modules hook implementation and the only message I'm receiving is a call with 'load' as the $op. I've confirmed that drupal_set_message can be called multiple times and it doesn't erase the previous message, so I'm confident that hook_user is only being invoked the one time. Any good reasons for why hook_user isn't being invoked with 'login' as an operation when I'm logging in?

    Read the article

< Previous Page | 61 62 63 64 65 66 67 68 69 70 71 72  | Next Page >